Skip to content

Commit 502aa7a

Browse files
authored
feat: release docker image (#209)
1 parent c60fb96 commit 502aa7a

File tree

7 files changed

+85
-6
lines changed

7 files changed

+85
-6
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
*.md
5+
dist

.github/workflows/docker.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docker Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*.*.*'
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup release flow
15+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Login to ghcr.io
21+
uses: docker/login-action@v2
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Docker meta
28+
id: meta
29+
uses: docker/metadata-action@v4
30+
with:
31+
images: ghcr.io/api7/adc
32+
tags: |
33+
type=ref,event=branch
34+
type=ref,event=pr
35+
type=match,pattern=portal-api/(.*),group=1
36+
37+
- name: Build and push
38+
uses: docker/build-push-action@v4
39+
with:
40+
context: .
41+
file: libs/tools/src/docker/Dockerfile
42+
push: ${{ github.event_name == 'push' }}
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
45+
provenance: false
46+
sbom: false

.github/workflows/update-s3-and-cloudfront.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ on:
55
- main
66
paths:
77
- .github/workflows/update-s3-and-cloudfront.yaml
8-
- s3/install
8+
- libs/tools/project.json
9+
- libs/tools/src/s3/install
910

1011
jobs:
1112
update-s3-and-cloudfront:
@@ -24,16 +25,16 @@ jobs:
2425
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
2526
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2627
aws-region: ${{ secrets.S3_BUCKET_REGION }}
27-
28+
2829
- name: Deploy
2930
# The path to the install script will be /adc/install
30-
run: aws s3 sync ./s3 s3://${{ secrets.S3_BUCKET }}/adc
31+
run: aws s3 sync ./libs/tools/src/s3 s3://${{ secrets.S3_BUCKET }}/adc
3132

3233
- name: Invalidate CloudFront
3334
uses: chetan/invalidate-cloudfront-action@v2
3435
env:
3536
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
36-
PATHS: "/"
37-
AWS_REGION: "${{ secrets.S3_BUCKET_REGION }}"
37+
PATHS: '/'
38+
AWS_REGION: '${{ secrets.S3_BUCKET_REGION }}'
3839
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
3940
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

libs/tools/project.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "tools",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/tools/src",
5+
"projectType": "library",
6+
"targets": {},
7+
"tags": []
8+
}

libs/tools/src/docker/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:bookworm-slim AS builder
2+
3+
ENV PNPM_HOME="/pnpm"
4+
ENV PATH="$PNPM_HOME:$PATH"
5+
RUN corepack enable
6+
7+
WORKDIR /build
8+
9+
COPY . .
10+
11+
RUN pnpm install nx -g \
12+
&& pnpm install \
13+
&& NODE_ENV=production nx build cli
14+
15+
FROM node:bookworm-slim
16+
17+
COPY --from=builder /build/dist/apps/cli/main.js .
18+
19+
ENTRYPOINT [ "node", "main.js" ]
File renamed without changes.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@
7070
"yaml": "^2.4.2",
7171
"zod": "^3.23.8"
7272
},
73-
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
73+
"packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387"
7474
}

0 commit comments

Comments
 (0)