-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from rene-bos/build-docker-images
Build docker images
- Loading branch information
Showing
5 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
name: Build Docker images | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release-* | ||
tags: | ||
- v* | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
uses: rene-bos/iw-ghdw-app/.github/workflows/ci.yml@main | ||
|
||
build-source: | ||
name: Build source | ||
needs: ci | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/rene-bos/iw-ghdw-php:8.1-ci-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install PHP dependencies | ||
run: composer install --no-dev --no-interaction --optimize-autoloader | ||
|
||
- name: Zip build artifact | ||
run: zip -r build-source.zip . | ||
|
||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build-source | ||
path: build-source.zip | ||
retention-days: 7 | ||
|
||
build-and-push-php: | ||
name: Build & push PHP image | ||
needs: build-source | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
env: | ||
IMAGE_NAME: rene-bos/iw-ghdw-app-php | ||
IMAGE_TITLE: IW GHDW App | PHP | ||
steps: | ||
- name: Download build source | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build-source | ||
|
||
- name: Unzip build source artifact | ||
run: | | ||
unzip build-source.zip -d . | ||
rm build-source.zip | ||
- name: Log in to container registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta-php | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
flavor: | | ||
latest=auto | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
type=edge,branch=main | ||
labels: | | ||
- org.opencontainers.image.title=${{ env.IMAGE_TITLE }} | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
file: ./infrastructure/docker/php/Dockerfile | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta-php.outputs.tags }} | ||
labels: ${{ steps.meta-php.outputs.labels }} | ||
|
||
build-and-push-web: | ||
name: Build & push web image | ||
needs: build-source | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
env: | ||
IMAGE_NAME: rene-bos/iw-ghdw-app-web | ||
IMAGE_TITLE: IW GHDW App | Web | ||
steps: | ||
- name: Download build source | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build-source | ||
|
||
- name: Unzip build source artifact | ||
run: | | ||
unzip build-source.zip -d . | ||
rm build-source.zip | ||
- name: Log in to container registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta-web | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
flavor: | | ||
latest=auto | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
type=edge,branch=main | ||
labels: | | ||
- org.opencontainers.image.title=${{ env.IMAGE_TITLE }} | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
file: ./infrastructure/docker/web/Dockerfile | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta-web.outputs.tags }} | ||
labels: ${{ steps.meta-web.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release-* | ||
pull_request: ~ | ||
pull_request: | ||
workflow_call: | ||
|
||
jobs: | ||
code-style: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "3.7" | ||
|
||
services: | ||
php: | ||
build: | ||
context: ./../.. | ||
dockerfile: ./infrastructure/docker/php/Dockerfile | ||
|
||
web: | ||
build: | ||
context: ./../.. | ||
dockerfile: ./infrastructure/docker/web/Dockerfile | ||
ports: | ||
- "6002:80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM ghcr.io/rene-bos/iw-ghdw-php:8.1-latest | ||
|
||
COPY . /app | ||
|
||
# Ensure PHP can write in the `var` folder | ||
RUN chmod -R 0777 /app/var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM ghcr.io/rene-bos/iw-ghdw-nginx:symfony-latest | ||
|
||
COPY . /app |