diff --git a/.github/workflows/build-base-images.yaml b/.github/workflows/build-base-images.yaml index cfcdbcd..bca3f8a 100644 --- a/.github/workflows/build-base-images.yaml +++ b/.github/workflows/build-base-images.yaml @@ -4,6 +4,7 @@ on: push: branches: - 'main' + - 'test_build' jobs: build: @@ -11,13 +12,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v2 @@ -26,17 +24,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # - name: Build drupal-base-cli image - # run: docker build -t uselagoon/drupal-base-cli:latest -t drupal-base-cli -f ./lagoon/cli.dockerfile . - - # - name: Build drupal-base-nginx image - # run: docker build -t uselagoon/drupal-base-nginx:latest -f ./lagoon/nginx.dockerfile . - - # - name: Build drupal-base-php image - # run: docker build -t uselagoon/drupal-base-php:latest -f ./lagoon/php.dockerfile . + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Build Docker images - run: docker compose -f docker-compose.yml build + - name: Build and push remote + uses: docker/bake-action@v5 + with: + push: true + set: | + *.platform=linux/amd64,linux/arm64 + cli.tags=ghcr.io/${{ github.repository_owner }}/drupal-base-image/cli:latest + nginx.tags=ghcr.io/${{ github.repository_owner }}/drupal-base-image/nginx:latest + php.tags=ghcr.io/${{ github.repository_owner }}/drupal-base-image/php:latest - name: Tag Docker images run: | @@ -47,10 +50,15 @@ jobs: - name: List images run: docker image ls - # - name: Push Docker images to Docker Hub - # run: | - # docker push uselagoon/drupal-base-image-cli:latest - # docker push uselagoon/drupal-base-image-php:latest - # docker push uselagoon/drupal-base-image-nginx:latest - # - name: Push Docker images to GitHub Container Registry - # run: docker push ghcr.io/your-github-username/your-app:latest \ No newline at end of file + - name: Build and push local + uses: docker/bake-action@v5 + with: + load: true + set: | + *.platform=linux/amd64 + cli.tags=drupal-base-cli:latest + nginx.tags=drupal-base-nginx:latest + php.tags=drupal-base-php:latest + + - name: List images + run: docker image ls diff --git a/docker-compose.yml b/docker-compose.yml index 734c529..906ad86 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,10 +28,12 @@ volumes: services: cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) + hostname: cli build: context: . - dockerfile: lagoon/cli.dockerfile - image: &cli-image ${COMPOSE_PROJECT_NAME:-drupal-base}-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds + target: cli + dockerfile: lagoon/Dockerfile + image: drupal-base-cli:latest labels: # Lagoon Labels lagoon.type: cli-persistent @@ -46,11 +48,12 @@ services: << : *default-environment # loads the defined environment variables from the top nginx: + hostname: nginx build: context: . - dockerfile: lagoon/nginx.dockerfile - args: - CLI_IMAGE: *cli-image # Inject the name of the cli image + target: nginx + dockerfile: lagoon/Dockerfile + image: drupal-base-nginx:latest labels: lagoon.type: nginx-php-persistent lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too @@ -68,11 +71,12 @@ services: - default php: + hostname: php build: context: . - dockerfile: lagoon/php.dockerfile - args: - CLI_IMAGE: *cli-image + target: php + dockerfile: lagoon/Dockerfile + image: drupal-base-php:latest labels: lagoon.type: nginx-php-persistent lagoon.name: nginx # we want this service be part of the nginx pod in Lagoon @@ -100,3 +104,4 @@ services: networks: amazeeio-network: external: true + default: diff --git a/lagoon/Dockerfile b/lagoon/Dockerfile new file mode 100644 index 0000000..23256f8 --- /dev/null +++ b/lagoon/Dockerfile @@ -0,0 +1,20 @@ +FROM uselagoon/php-8.3-cli-drupal:latest AS cli + +COPY composer.* /app/ +COPY assets /app/assets +RUN --mount=type=cache,target=/home/.composer/cache composer install --no-dev +COPY . /app +RUN mkdir -p -v -m775 /app/web/sites/default/files + +# Define where the Drupal Root is located +ENV WEBROOT=web + +FROM uselagoon/nginx-drupal:latest AS nginx + +COPY --from=cli /app /app + +ENV WEBROOT=web + +FROM uselagoon/php-8.3-fpm:latest AS php + +COPY --from=cli /app /app diff --git a/lagoon/cli.dockerfile b/lagoon/cli.dockerfile deleted file mode 100644 index eba950a..0000000 --- a/lagoon/cli.dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM uselagoon/php-8.3-cli-drupal:latest - -COPY composer.* /app/ -COPY assets /app/assets -RUN composer install --no-dev -COPY . /app -RUN mkdir -p -v -m775 /app/web/sites/default/files - -# Define where the Drupal Root is located -ENV WEBROOT=web diff --git a/lagoon/nginx.dockerfile b/lagoon/nginx.dockerfile deleted file mode 100644 index ba5773a..0000000 --- a/lagoon/nginx.dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -ARG CLI_IMAGE=drupal-base-cli -FROM ${CLI_IMAGE} AS cli - -FROM uselagoon/nginx-drupal:latest - -COPY --from=cli /app /app - -# Define where the Drupal Root is located -ENV WEBROOT=web diff --git a/lagoon/php.dockerfile b/lagoon/php.dockerfile deleted file mode 100644 index 9137bfa..0000000 --- a/lagoon/php.dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -ARG CLI_IMAGE=drupal-base-cli -FROM ${CLI_IMAGE} AS cli - -FROM uselagoon/php-8.3-fpm:latest - -COPY --from=cli /app /app