Skip to content
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# in frontend's environment.*.ts, as well as nginx.conf
API_PATH=/api

# App log level, mainly for the unicorn command in start.py
# App log level, mainly for the uvicorn command in start.py
# critical, error, warning, info, debug, trace
LOG_LEVEL=warning

Expand Down
97 changes: 32 additions & 65 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,51 @@
name: Build and Push Docker Image on Version Tag
name: Build and push docker image with arbitrary tag

on:
# push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
version:
description: "Tag version to build (e.g. v1.2.3), this will be the docker-image tag"
tag:
description: 'Tag of the image being built (e.g. dev). Cannot start with "v" or be "latest".'
required: true
# workflow_run:
# workflows: ["Semantic Release"]
# types:
# - completed

jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
exists: ${{ steps.check_tag.outputs.exists }}
env:
IMAGE_NAME: quenary/cardholder_pwa

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine version
id: version
run: |
VERSION="${{ github.event.inputs.version }}"

if [ -z "$VERSION" ]; then
echo "❌ ERROR: No version tag found. Aborting."
exit 1
fi

echo "✅ Using VERSION=$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Check if Docker tag already exists
id: check_tag
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
https://hub.docker.com/v2/repositories/${{ env.IMAGE_NAME }}/tags/${{ steps.version.outputs.version }}/)
echo "Status: $STATUS"
if [ "$STATUS" = "200" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

build:
needs: check-tag
if: needs.check-tag.outputs.version != '' && needs.check-tag.outputs.exists == 'false'
if: github.event.inputs.tag != 'latest' && !startsWith(github.event.inputs.tag, 'v')
runs-on: ubuntu-latest
env:
IMAGE_NAME: quenary/cardholder_pwa
VERSION: ${{ needs.check-tag.outputs.version }}
TAG: ${{ github.event.inputs.tag }}

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

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build and tag Docker image
run: |
docker build \
--build-arg VERSION=${{ env.VERSION }} \
-t $IMAGE_NAME:${{ env.VERSION }} \
-t $IMAGE_NAME:latest .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Push Docker image (${{ env.VERSION }})
run: docker push $IMAGE_NAME:${{ env.VERSION }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Push Docker image (latest)
run: docker push $IMAGE_NAME:latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.TAG }}
build-args: |
VERSION=${{ env.TAG }}
labels: |
org.opencontainers.image.title="Cardholder PWA"
org.opencontainers.image.description="An app for your loyalty and discount cards."
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
org.opencontainers.image.created=${{ github.run_started_at }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=MIT
44 changes: 31 additions & 13 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- name: Install backend dependencies
run: |
Expand Down Expand Up @@ -148,24 +148,42 @@ jobs:
with:
fetch-depth: 0

# Semantic-release pushes new tag and modifies some files
- name: Fetch latest refs explicitly
run: |
git fetch origin main
git fetch --tags
git reset --hard origin/main

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build and tag Docker image
run: |
docker build \
--build-arg VERSION=${{ env.VERSION }} \
-t $IMAGE_NAME:${{ env.VERSION }} \
-t $IMAGE_NAME:latest .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Push Docker image (${{ env.VERSION }})
run: docker push $IMAGE_NAME:${{ env.VERSION }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Push Docker image (latest)
run: docker push $IMAGE_NAME:latest
- name: Build and push full image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
build-args: |
VERSION=${{ env.VERSION }}
labels: |
org.opencontainers.image.title="Cardholder PWA"
org.opencontainers.image.description="An app for your loyalty and discount cards."
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ env.VERSION }}
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.created=${{ github.run_started_at }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=MIT
156 changes: 155 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,155 @@
/node_modules
**/cardholder_pwa.db

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.*
!.env.example

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Sveltekit cache directory
.svelte-kit/

# vitepress build output
**/.vitepress/dist

# vitepress cache directory
**/.vitepress/cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Firebase cache directory
.firebase/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v3
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Vite logs files
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

# PYTHON
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{
}
"python.terminal.activateEnvironment": true,
"python.venvPath": ".venv",
"python.languageServer": "None"
}
Loading