-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Release Image | ||
on: | ||
push: | ||
branches: | ||
- mpw/cicd | ||
- main | ||
- release | ||
paths-ignore: | ||
- 'README.md' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
SERVICE_NAME: uploads | ||
CACHE_CONFIG: type=s3,region=${{ vars.AWS_REGION }},bucket=${{ vars.AWS_BUCKET }},access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }},secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
DOCKERHUB_REPO: ${{ vars.DOCKERHUB_ORG }}/${{ env.SERVICE_NAME }} | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
arch: [amd64, arm64] | ||
runs-on: ${{ matrix.arch }} | ||
environment: release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- run: | | ||
docker context create ci | ||
docker context use ci | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
driver-opts: image=moby/buildkit:master | ||
version: v0.11.2 | ||
endpoint: ci | ||
|
||
- uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-region: ${{ vars.AWS_REGION }} | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
- name: Build and push ${{ env.SERVICE_NAME }} | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
provenance: false | ||
platforms: linux/${{ matrix.arch }} | ||
tags: ${{ env.DOCKERHUB_REPO }}:latest-${{ matrix.arch }} | ||
cache-from: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ env.SERVICE_NAME }}/${{ matrix.arch }}/ | ||
cache-to: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ env.SERVICE_NAME }}/${{ matrix.arch }}/,mode=max | ||
|
||
finalize: | ||
needs: build | ||
environment: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Merge image tags | ||
uses: Noelware/docker-manifest-action@master | ||
with: | ||
inputs: ${{ env.DOCKERHUB_REPO }}:latest,${{ env.DOCKERHUB_REPO }}:${{ github.sha }} | ||
images: ${{ env.DOCKERHUB_REPO }}:latest-amd64,${{ env.DOCKERHUB_REPO }}:latest-arm64 | ||
push: true | ||
|
||
- name: Setup variables | ||
id: vars | ||
run: | | ||
if [[ "${{ github.ref }}" == "refs/heads/release" ]]; then | ||
echo "::set-output name=environment::prod" | ||
else | ||
echo "::set-output name=environment::stage" | ||
fi | ||
- name: Invoke workflow in hub-kubes repo | ||
uses: benc-uk/workflow-dispatch@v1 | ||
with: | ||
ref: main | ||
token: ${{ secrets.ACTIONS_TOKEN }} | ||
workflow: release.yml | ||
repo: holaplex/hub-kubes | ||
inputs: '{ "service": "${{ env.SERVICE_NAME }}", "environment": "${{ steps.vars.outputs.environment }}", "commit_hash": "${{ github.sha }}"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM node:20-alpine AS base | ||
WORKDIR /app | ||
COPY package*.json ./ | ||
|
||
FROM base AS dependencies | ||
RUN npm set progress=false && npm config set depth 0 && \ | ||
npm install --only=production | ||
RUN cp -R node_modules prod_node_modules | ||
RUN npm install | ||
|
||
FROM dependencies AS build | ||
ENV NODE_ENV=production | ||
COPY . . | ||
|
||
# --- Release ---- | ||
FROM base AS release | ||
COPY --from=dependencies /app/prod_node_modules ./node_modules | ||
COPY . . | ||
EXPOSE 3000 | ||
CMD ["npm","start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters