Skip to content

Commit 689b9ad

Browse files
authored
Merge pull request #6 from mapswipe/feat/push-docker-image
feat: add docker push workflow
2 parents 55f9f9e + 4d67264 commit 689b9ad

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
push: false
59+
load: true
60+
provenance: false # XXX: Without this we have untagged images in ghcr.io
61+
tags: ${{ steps.prep.outputs.docker_image }}
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max
64+
65+
- name: 🐳 Docker push
66+
if: github.event_name != 'pull_request'
67+
env:
68+
DOCKER_IMAGE: ${{ steps.prep.outputs.docker_image }}
69+
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: If you make any BREAKING CHANGE:
2+
# - Update the Docker image tag in `./.github/workflows/docker-push-dev.yml`
3+
# - Update the `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)