Skip to content

Commit

Permalink
change docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaStelmashchuk committed Jan 17, 2025
1 parent bcb69da commit adf4444
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 35 deletions.
65 changes: 37 additions & 28 deletions .github/workflows/publich.yml
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 }}
27 changes: 20 additions & 7 deletions Dockerfile
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" ]

0 comments on commit adf4444

Please sign in to comment.