-
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
1 parent
bcb69da
commit adf4444
Showing
2 changed files
with
57 additions
and
35 deletions.
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 |
---|---|---|
@@ -1,38 +1,47 @@ | ||
name: Publish Docker image | ||
name: Deploy docker image and update production | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
push: | ||
branches: | ||
- "main" | ||
|
||
env: | ||
DOCKERHUB_REPO: mixdrinks-web | ||
REGISTRY: ghcr.io | ||
DOCKER_STACKE_NAME: stack-mixdrinks | ||
DEPLOY_USER: deploy | ||
HOST: 167.235.52.168 | ||
|
||
jobs: | ||
build_and_push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
|
||
- name: Get short SHA | ||
id: sha | ||
run: echo "::set-output name=sha::$(git rev-parse --short ${{ github.sha }})" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Get repository name in lowercase | ||
id: repo_name | ||
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:${{ steps.sha.outputs.sha }} | ||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:latest | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.REPO_NAME }}:latest | ||
${{ env.REGISTRY }}/${{ env.REPO_NAME }}:${{ github.sha }} | ||
build-args: | | ||
GIT_COMMIT_SHA=${{ 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 |
---|---|---|
@@ -1,14 +1,27 @@ | ||
FROM node:20.18.0 | ||
ARG NODE_VERSION=20.18.0 | ||
|
||
WORKDIR /app | ||
FROM node:${NODE_VERSION}-slim as base | ||
|
||
COPY package*.json ./ | ||
ARG PORT=3000 | ||
ARG GIT_COMMIT_SHA | ||
|
||
RUN npm install | ||
WORKDIR /src | ||
|
||
FROM base as build | ||
|
||
COPY . . | ||
COPY --link package.json package-lock.json . | ||
RUN npm install | ||
|
||
EXPOSE 3000 | ||
COPY --link . . | ||
|
||
RUN npm run build | ||
CMD [ "npm", "run", "start" ] | ||
|
||
FROM base | ||
|
||
ENV PORT=$PORT | ||
ENV NODE_ENV=production | ||
ENV NUXT_PUBLIC_GIT_COMMIT_SHA=$GIT_COMMIT_SHA | ||
|
||
COPY --from=build /src/.output /src/.output | ||
|
||
CMD [ "node", ".output/server/index.mjs" ] |