Skip to content

Commit

Permalink
feat: add container builds
Browse files Browse the repository at this point in the history
  • Loading branch information
esolitos committed Mar 4, 2024
1 parent aa95851 commit 64ae5b6
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Container Images

on:
push:
branches:
- master
- build-container # This branch is used to test the container build workflow.
tags:
- v*

env:
REGISTRY: ghcr.io
PHP_CONTAINER_TAG: 7.4-4.33.4
NGINX_CONTAINER_TAG: 1.25-5.34.2

jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
include:
- container-name: php
base-tag: ${{ env.PHP_CONTAINER_TAG }}
- container-name: nginx
base-tag: ${{ env.NGINX_CONTAINER_TAG }}

env:
CONTAINER_NAME: ${{ github.repository }}/${{ matrix.container-name }}
BASE_CONTAINER_TAG: ${{ matrix.base-tag }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract container metadata
id: meta
uses: docker/metadata-action@v4
with:
images: "${{ env.REGISTRY }}/${{ env.CONTAINER_NAME }}"

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
file: ./containers/${{ matrix.container-name }}/Dockerfile
build-args: |
BASE_TAG=${{ env.BASE_CONTAINER_TAG }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 6 additions & 0 deletions containers/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG BASE_TAG=1
FROM wodby/nginx:${BASE_TAG}

ENV NGINX_VHOST_PRESET=php

COPY --chown=wodby:wodby . .
14 changes: 14 additions & 0 deletions containers/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG BASE_TAG=7.4
FROM wodby/php:${BASE_TAG}

COPY --chown=wodby:wodby . .

RUN set -euo pipefail ; \
composer self-update --1 ; \
composer install --no-dev --no-interaction --no-progress --no-suggest --optimize-autoloader

USER root
RUN set -euo pipefail ; \
ls -l /var/www/html ; \
chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache ;
USER wodby

0 comments on commit 64ae5b6

Please sign in to comment.