Skip to content

Commit

Permalink
feat: release docker image (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 authored Nov 26, 2024
1 parent c60fb96 commit 502aa7a
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.git
.gitignore
*.md
dist
46 changes: 46 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Docker Release
on:
push:
tags:
- 'v*.*.*'
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup release flow
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/api7/adc
tags: |
type=ref,event=branch
type=ref,event=pr
type=match,pattern=portal-api/(.*),group=1
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: libs/tools/src/docker/Dockerfile
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
sbom: false
11 changes: 6 additions & 5 deletions .github/workflows/update-s3-and-cloudfront.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
- main
paths:
- .github/workflows/update-s3-and-cloudfront.yaml
- s3/install
- libs/tools/project.json
- libs/tools/src/s3/install

jobs:
update-s3-and-cloudfront:
Expand All @@ -24,16 +25,16 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.S3_BUCKET_REGION }}

- name: Deploy
# The path to the install script will be /adc/install
run: aws s3 sync ./s3 s3://${{ secrets.S3_BUCKET }}/adc
run: aws s3 sync ./libs/tools/src/s3 s3://${{ secrets.S3_BUCKET }}/adc

- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
PATHS: "/"
AWS_REGION: "${{ secrets.S3_BUCKET_REGION }}"
PATHS: '/'
AWS_REGION: '${{ secrets.S3_BUCKET_REGION }}'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
8 changes: 8 additions & 0 deletions libs/tools/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "tools",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/tools/src",
"projectType": "library",
"targets": {},
"tags": []
}
19 changes: 19 additions & 0 deletions libs/tools/src/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:bookworm-slim AS builder

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /build

COPY . .

RUN pnpm install nx -g \
&& pnpm install \
&& NODE_ENV=production nx build cli

FROM node:bookworm-slim

COPY --from=builder /build/dist/apps/cli/main.js .

ENTRYPOINT [ "node", "main.js" ]
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
"yaml": "^2.4.2",
"zod": "^3.23.8"
},
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
"packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387"
}

0 comments on commit 502aa7a

Please sign in to comment.