From 5fe880e46c5c38f64d270f47790c99297ab027f3 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 30 Nov 2023 15:30:31 +0200 Subject: [PATCH] Adding the files and jobs requires to build the production Docker image --- .github/workflows/build-push-docker-image.yml | 47 +++++++++++++++++++ .github/workflows/tag-release.yml | 9 ++++ docker/Dockerfile.prod | 13 +++++ 3 files changed, 69 insertions(+) create mode 100644 .github/workflows/build-push-docker-image.yml create mode 100644 docker/Dockerfile.prod diff --git a/.github/workflows/build-push-docker-image.yml b/.github/workflows/build-push-docker-image.yml new file mode 100644 index 000000000..c31b8a0a6 --- /dev/null +++ b/.github/workflows/build-push-docker-image.yml @@ -0,0 +1,47 @@ +name: build-push-docker-image + +on: + push: + branches: feature/docker_configs + workflow_dispatch: + +jobs: + build-push-docker-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Get the latest release + id: release + uses: robinraju/release-downloader@v1.7 + with: + latest: true + fileName: "*.tar.bz2" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push the Production image + uses: docker/build-push-action@v4 + with: + context: . + file: docker/Dockerfile.prod + platforms: linux/amd64 + push: true + tags: | + ghcr.io/openconext/openconext-engineblock/openconext-engineblock:prod + ghcr.io/openconext/openconext-engineblock/openconext-engineblock:${{ github.sha }} + ghcr.io/openconext/openconext-engineblock/openconext-engineblock:${{ steps.release.outputs.tag_name }} diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 18feea7af..66d857a12 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -55,3 +55,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_id: ${{ steps.create_release.outputs.id }} + + after_build: + needs: build + runs-on: ubuntu-latest + steps: + - name: Trigger Docker container build + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: build-push-docker-image.yml diff --git a/docker/Dockerfile.prod b/docker/Dockerfile.prod new file mode 100644 index 000000000..677dde360 --- /dev/null +++ b/docker/Dockerfile.prod @@ -0,0 +1,13 @@ +FROM ghcr.io/openconext/openconext-basecontainers/php72-apache2:latest AS php-build +COPY *.tar.bz2 /tmp/ +RUN tar -xvjf /tmp/*.tar.bz2 -C /var/www/html/ && \ + rm -rf /tmp/*.tar.bz2 + +# Add the config files for Apache2 +RUN rm -rf /etc/apache2/sites-enabled/* +COPY ./docker/php-fpm/apache2.conf /etc/apache2/sites-enabled/apache2.conf + +# Set the default workdir +WORKDIR /var/www/html +EXPOSE 80 +CMD ["apache2-foreground"]