Skip to content

Commit 213a209

Browse files
committed
[F] Add Docker build and release CI
- Creates API and client images and pushes to both GHCR and DOCR
1 parent c326270 commit 213a209

File tree

3 files changed

+137
-2
lines changed

3 files changed

+137
-2
lines changed

.github/workflows/docker.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: "Build & Push Docker"
2+
3+
on:
4+
push:
5+
branches:
6+
- next # Next, tags as "next"
7+
- master # Edge, tags as "edge"
8+
- release # Production, tags as "latest"
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
env:
15+
GHCR_REGISTRY: ghcr.io
16+
GHCR_IMAGE_NAME: ${{ github.repository }}
17+
MANAGED_REGISTRY: registry.digitalocean.com
18+
MANAGED_IMAGE_NAME: manifold/manifold
19+
20+
jobs:
21+
build-api:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
- name: Login GHCR
30+
uses: docker/login-action@v4
31+
with:
32+
registry: ${{ env.GHCR_REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Login DOCR
36+
uses: docker/login-action@v4
37+
with:
38+
registry: ${{ env.MANAGED_REGISTRY }}
39+
username: docr
40+
password: ${{ secrets.DOCR_TOKEN }}
41+
- name: Docker meta
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: |
46+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}-api
47+
${{ env.MANAGED_REGISTRY }}/${{ env.MANAGED_IMAGE_NAME }}-api
48+
tags: |
49+
type=raw,value=latest,enable=${{ github.ref_name == 'release' }}
50+
type=raw,value=edge,enable={{ is_default_branch }}
51+
type=ref,event=branch
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
- name: Build and push Docker
55+
id: push
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: ./api
59+
target: production
60+
push: true
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
build-args:
66+
"RAILS_ENV=production"
67+
68+
build-client:
69+
runs-on: ubuntu-latest
70+
permissions:
71+
contents: read
72+
packages: write
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
- name: Login GHCR
77+
uses: docker/login-action@v4
78+
with:
79+
registry: ${{ env.GHCR_REGISTRY }}
80+
username: ${{ github.actor }}
81+
password: ${{ secrets.GITHUB_TOKEN }}
82+
- name: Login DOCR
83+
uses: docker/login-action@v4
84+
with:
85+
registry: ${{ env.MANAGED_REGISTRY }}
86+
username: docr
87+
password: ${{ secrets.DOCR_TOKEN }}
88+
- name: Docker meta
89+
id: meta
90+
uses: docker/metadata-action@v5
91+
with:
92+
images: |
93+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}-client
94+
${{ env.MANAGED_REGISTRY }}/${{ env.MANAGED_IMAGE_NAME }}-client
95+
tags: |
96+
type=raw,value=latest,enable=${{ github.ref_name == 'release' }}
97+
type=raw,value=edge,enable={{ is_default_branch }}
98+
type=ref,event=branch
99+
- name: Set up Docker Buildx
100+
uses: docker/setup-buildx-action@v3
101+
- name: Build and push Docker
102+
id: push
103+
uses: docker/build-push-action@v5
104+
with:
105+
context: ./client
106+
target: production
107+
push: true
108+
cache-from: type=gha
109+
cache-to: type=gha,mode=max
110+
tags: ${{ steps.meta.outputs.tags }}
111+
labels: ${{ steps.meta.outputs.labels }}
112+
build-args:
113+
"RAILS_ENV=production"

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Production Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
name: Update Release Branch
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: "checkout release-candidate"
12+
uses: actions/checkout@v4
13+
with:
14+
ref: release
15+
16+
- name: "Push release changes"
17+
env:
18+
GH_TOKEN: ${{ github.token }}
19+
run: |
20+
git fetch
21+
git reset --hard origin/master
22+
git push --force origin release

client/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ COPY ./ /srv/app
55

66
RUN yarn
77

8-
FROM base AS dev
8+
FROM base AS development
99

1010
RUN yarn build:dev
1111

1212
EXPOSE 3010 3011 3012
1313

1414
CMD ["yarn", "run", "watch"]
1515

16-
FROM base AS prod
16+
FROM base AS production
1717

1818
RUN yarn build:prod
1919

0 commit comments

Comments
 (0)