Skip to content

refactor: replace production docker-compose configuration with a samp… #10

refactor: replace production docker-compose configuration with a samp…

refactor: replace production docker-compose configuration with a samp… #10

name: 🐳 Build and Push Docker Images
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-backend:
name: 🛠️ Build and Push Backend
runs-on: ubuntu-latest
steps:
- name: 🚀 Checkout Code
uses: actions/checkout@v4
- name: 🏗️ Set Build Variables
run: |
echo "GIT_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "GIT_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- 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.actor }}
password: ${{ secrets.TOKEN }}
- name: 📦 Build and Push Backend Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/kek-sec/gopherdrop:backend-latest
annotations: |
org.opencontainers.image.description=Backend API for GopherDrop, a secure one-time secret sharing service
build-args: |
GIT_COMMIT_SHA=${{ env.GIT_COMMIT_SHA }}
GIT_VERSION=${{ env.GIT_VERSION }}
labels: |
org.opencontainers.image.source=https://github.com/kek-sec/gopherdrop
org.opencontainers.image.revision=${{ env.GIT_COMMIT_SHA }}
org.opencontainers.image.version=${{ env.GIT_VERSION }}
cache-from: type=registry,ref=ghcr.io/kek-sec/gopherdrop:backend-latest
cache-to: type=inline
build-ui:
name: 🖥️ Build and Push UI
runs-on: ubuntu-latest
steps:
- name: 🚀 Checkout Code
uses: actions/checkout@v4
- name: 🏗️ Set Build Variables
run: |
echo "GIT_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "GIT_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- 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.actor }}
password: ${{ secrets.TOKEN }}
- name: 📦 Build and Push UI Image
uses: docker/build-push-action@v4
with:
context: ./ui
file: ./ui/Dockerfile
push: true
tags: ghcr.io/kek-sec/gopherdrop:ui-latest
annotations: |
org.opencontainers.image.description=UI for GopherDrop, a secure one-time secret sharing service
build-args: |
GIT_COMMIT_SHA=${{ env.GIT_COMMIT_SHA }}
GIT_VERSION=${{ env.GIT_VERSION }}
labels: |
org.opencontainers.image.source=https://github.com/kek-sec/gopherdrop
org.opencontainers.image.revision=${{ env.GIT_COMMIT_SHA }}
org.opencontainers.image.version=${{ env.GIT_VERSION }}
cache-from: type=registry,ref=ghcr.io/kek-sec/gopherdrop:ui-latest
cache-to: type=inline