Skip to content

feat: add production build #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
fail-fast: true
matrix:
os_name: ["alpine"]
php_version: ["8.1", "8.2"]
php_type: ["fpm", "cli", "supervisord"]
php_version: ["8.1"]
php_type: ["fpm"]
# php_version: ["8.1", "8.2"]
# php_type: ["fpm", "cli", "supervisord"]
environment:
name: latest
url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1&name=latest
Expand Down Expand Up @@ -70,16 +72,17 @@ jobs:
with:
platforms: arm64

- name: 🛠️ Setup Docker Buildx
- name: 🛠️ Setup docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: 🚀 Build and Export to Docker
- name: 🚀 Build image and push to docker-hub
uses: docker/build-push-action@v4
with:
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
load: true
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -88,14 +91,4 @@ jobs:
- name: 🧪 Test Docker image with "latest" tag
run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test

- name: 📤 Push Docker image
uses: docker/build-push-action@v4
with:
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

...
93 changes: 93 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---

on: # yamllint disable-line rule:truthy
release:
types:
- released

name: 🚀 Build docker images with release tag

jobs:
build:
runs-on: "ubuntu-latest"
strategy:
fail-fast: true
matrix:
os_name: ["alpine"]
php_version: [ "8.1" ]
php_type: [ "fpm" ]
# php_version: ["8.1", "8.2"]
# php_type: ["fpm", "cli", "supervisord"]
environment:
name: release
url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1

steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v3

- name: 🛠️ Install goss and dgoss
uses: e1himself/goss-installation-action@v1.1.0

- name: 🌎 Set environment variables
env:
IMAGE_NAMESPACE: wayofdev/php-base
IMAGE_TEMPLATE: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
IMAGE_TAG: wayofdev/php-base:${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ env.VERSION }}
run: |
export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \
&& { \
echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \
echo "IMAGE_TEMPLATE=${IMAGE_TEMPLATE}"; \
echo "VERSION=${RELEASE_VERSION:1}"; \
} >> "$GITHUB_ENV"

- name: 🤖 Generate dist files
run: make generate

- name: 🐳 Extract docker meta data
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAMESPACE }}
tags: |
type=raw,event=branch,value=latest
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=false
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-

- name: 🔑 Login to docker-hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: 🖥️ Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- name: 🛠️ Setup docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: 🚀 Build image and push to docker-hub
uses: docker/build-push-action@v4
with:
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.meta.outputs.labels }}

- name: 🧪 Test Docker image with "version" tag
run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test

...