Skip to content

Commit eec36a4

Browse files
committed
feat: add docker push workflow
1 parent 9a05e56 commit eec36a4

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Docker publish dev
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "develop"
8+
pull_request:
9+
10+
jobs:
11+
docker-publish:
12+
name: Publish docker
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: 🐳 Prepare Docker
19+
id: prep
20+
env:
21+
REPO_NAME: ghcr.io/${{ github.repository }}
22+
run: |
23+
REPO_NAME=$(echo $REPO_NAME | tr '[:upper:]' '[:lower:]')
24+
TAG="0.0.1-dev"
25+
26+
# Docker
27+
echo "docker_image_name=${REPO_NAME}" >> $GITHUB_OUTPUT
28+
echo "docker_image_tag=${TAG}" >> $GITHUB_OUTPUT
29+
echo "docker_image=${REPO_NAME}:${TAG}" >> $GITHUB_OUTPUT
30+
31+
- name: Login to GitHub Container Registry
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: 🐳 Set up Docker Buildx
40+
id: buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: 🐳 Cache Docker layers
44+
uses: actions/cache@v4
45+
with:
46+
path: /tmp/.buildx-cache
47+
key: ${{ runner.os }}-buildx-${{ github.ref }}
48+
restore-keys: |
49+
${{ runner.os }}-buildx-refs/develop
50+
${{ runner.os }}-buildx-
51+
52+
- name: 🐳 Build image
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
builder: ${{ steps.buildx.outputs.name }}
57+
file: Dockerfile
58+
target: web-app-serve
59+
push: false
60+
load: true
61+
provenance: false # XXX: Without this we have untagged images in ghcr.io
62+
tags: ${{ steps.prep.outputs.docker_image }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
66+
- name: 🐳 Docker push
67+
if: github.event_name != 'pull_request'
68+
env:
69+
DOCKER_IMAGE: ${{ steps.prep.outputs.docker_image }}
70+
run: docker push $DOCKER_IMAGE

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# NOTE: After making BREAKING CHANGE
2+
# Make sure to bump the docker image tag in ./.github/workflows/docker-push-dev.yml
3+
# and update mapswipe-backend workflow to use the new image tag
14
FROM node:22-bullseye-slim
25

36
RUN apt-get update -y \

0 commit comments

Comments
 (0)