Skip to content

Commit

Permalink
Merge pull request #3 from potathon/develop
Browse files Browse the repository at this point in the history
Develop - init: dockerfile&github-actions
  • Loading branch information
TopazKang authored Oct 2, 2024
2 parents 9e5799f + b44cb79 commit 107d56a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/github-actions-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Front-Prod build & deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: TopazKang
password: ${{ secrets.GHCR_TOKEN }}

- name: Build Docker image
run: |
docker build \
--build-arg DB_NAME=${{ secrets.DB_NAME }} \
--build-arg DB_USER=${{ secrets.DB_USER }} \
--build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
--build-arg DB_HOST=${{ secrets.DB_HOST }} \
--build-arg DB_PORT=${{ secrets.DB_PORT }} \
-t ghcr.io/topazkang/ddeep-prod-be:latest .
- name: Push Docker image to GHCR
run: docker push ghcr.io/topazkang/ddeep-prod-be:latest

deploy:
runs-on: [ self-hosted, Linux, X64, ddeep-prod-be ]
name: Deploy on Self-Hosted Runner
needs: build

steps:
- name: set env & deploy
run: |
cd /home/ubuntu/deploy/be
docker-compose -f docker-compose.back.yaml up -d
25 changes: 25 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:20-alpine

WORKDIR /app

ARG DB_NAME
ARG DB_USER
ARG DB_PASSWORD
ARG DB_HOST
ARG DB_PORT

ENV DB_NAME=${DB_NAME}
ENV DB_USER=${DB_USER}
ENV DB_PASSWORD=${DB_PASSWORD}
ENV DB_HOST=${DB_HOST}
ENV DB_PORT=${DB_PORT}

COPY package*.json .

RUN npm install

COPY . .

EXPOSE 3008

CMD ["npm", "start"]

0 comments on commit 107d56a

Please sign in to comment.