-
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
b88e8b8
commit 32fef6a
Showing
7 changed files
with
180 additions
and
4,833 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,13 @@ | ||
FROM node:20-alpine AS builder | ||
ENV NODE_ENV production | ||
|
||
WORKDIR /app | ||
|
||
COPY ./back/package.json . | ||
COPY ./back/package-lock.json . | ||
|
||
RUN npm install --omit=dev | ||
|
||
COPY ./back . | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM node:20-alpine AS builder | ||
ENV NODE_ENV production | ||
|
||
WORKDIR /app | ||
|
||
COPY ./front/package.json . | ||
COPY ./front/package-lock.json . | ||
|
||
RUN npm install --omit=dev | ||
|
||
COPY ./front . | ||
|
||
RUN npm run build | ||
|
||
# Bundle static assets with nginx | ||
FROM nginx:1.25.3-alpine as production | ||
ENV NODE_ENV production | ||
# Copy built assets from builder | ||
COPY --from=builder /app/build /usr/share/nginx/html | ||
# Add your nginx.conf | ||
COPY ./.docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf | ||
# Start nginx | ||
CMD ["nginx", "-g", "daemon off;"] |
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 @@ | ||
server { | ||
listen 80; | ||
root /usr/share/nginx/html; | ||
|
||
location / { | ||
include /etc/nginx/mime.types; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
# Cache static assets | ||
location ~* \.(?:jpg|jpeg|gif|png|ico|svg)$ { | ||
expires 7d; | ||
add_header Cache-Control "public"; | ||
} | ||
|
||
# Cache css and js bundle | ||
location ~* \.(?:css|js)$ { | ||
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate"; | ||
} | ||
} |
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,82 @@ | ||
name: "Build and Push Production Build" | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
ENV_VARS_FRONT: | ||
description: "Environment Variables in Client (@/front/.env)" | ||
required: true | ||
ENV_VARS_BACK: | ||
description: "Environment Variables in Server (@/back/.env)" | ||
required: true | ||
HOST: | ||
description: "Server Host" | ||
required: true | ||
USERNAME: | ||
description: "Server Username" | ||
required: true | ||
PASSWORD: | ||
description: "Server Password" | ||
required: true | ||
|
||
jobs: | ||
publish-docker-image: | ||
name: "Build and Publish Latest Docker Image" | ||
runs-on: ubuntu-22.04 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- dockerfile: ./.docker/Front.Dockerfile | ||
image: ghcr.io/sparcs-kaist/sparcs-clubs-front | ||
- dockerfile: ./.docker/Back.Dockerfile | ||
image: ghcr.io/sparcs-kaist/sparcs-clubs-back | ||
|
||
steps: | ||
- name: "Checkout Repository" | ||
uses: actions/checkout@v2 | ||
|
||
- name: "Create .env File" | ||
run: | | ||
echo "Creating .env file" | ||
echo "${{ secrets.ENV_VARS_FRONT }}" >> front/.env | ||
echo "${{ secrets.ENV_VARS_BACK }}" >> back/.env | ||
echo "done" | ||
- name: "Log in to Github Container Registry" | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: "ghcr.io" | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: "Extract Metadata" | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ matrix.image }} | ||
labels: latest | ||
|
||
- name: Build and push Docker image Drill4Net.Agent.Service | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ${{ matrix.dockerfile }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
deploy-production-image: | ||
name: "Deploy Production Image in Server" | ||
needs: [publish-docker-image] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: "Run Remote Pull & Build Script" | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
sudo /home/${{ secrets.USERNAME }}/redeploy.sh ${{ github.actor }} ${{ secrets.GITHUB_TOKEN }} |
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,24 @@ | ||
name: Continuous Deployment to Production Server | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
- "!*-rc*" | ||
- "!*-alpha*" | ||
- "!*-beta*" | ||
|
||
concurrency: | ||
group: cd-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
deploy-production: | ||
name: "Deploy Production Build (CD)" | ||
uses: "./.github/workflows/build-and-push.yml" | ||
secrets: | ||
ENV_VARS_FRONT: ${{ secrets.ENV_VARS_FRONT }} | ||
ENV_VARS_BACK: ${{ secrets.ENV_VARS_BACK }} | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
PASSWORD: ${{ secrets.PASSWORD }} |
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,17 @@ | ||
version: "3.8" | ||
|
||
services: | ||
client: | ||
container_name: sparcs-clubs-front | ||
image: sparcs-clubs-front | ||
build: | ||
context: . | ||
dockerfile: .docker/Front.Dockerfile | ||
target: production | ||
|
||
back: | ||
container_name: sparcs-clubs-back | ||
image: sparcs-clubs-back | ||
build: | ||
context: . | ||
dockerfile: .docker/Back.Dockerfile |
Oops, something went wrong.