-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from potathon/develop
Develop - init: dockerfile&github-actions
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 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 |
---|---|---|
@@ -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 |
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,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"] |