Skip to content

Commit

Permalink
Merge pull request #5 from tobybellwood/test_build
Browse files Browse the repository at this point in the history
Test build
  • Loading branch information
bomoko authored Aug 6, 2024
2 parents 9dc54b7 + 6a7ee3c commit 7d91eda
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 56 deletions.
54 changes: 31 additions & 23 deletions .github/workflows/build-base-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ on:
push:
branches:
- 'main'
- 'test_build'

jobs:
build:
runs-on: ubuntu-latest

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
Expand All @@ -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: |
Expand All @@ -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
- 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
21 changes: 13 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -100,3 +104,4 @@ services:
networks:
amazeeio-network:
external: true
default:
20 changes: 20 additions & 0 deletions lagoon/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 0 additions & 10 deletions lagoon/cli.dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions lagoon/nginx.dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions lagoon/php.dockerfile

This file was deleted.

0 comments on commit 7d91eda

Please sign in to comment.