-
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.
add build and deploy github workflow
- Loading branch information
Showing
3 changed files
with
58 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,37 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Build and Push Docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to Docker registry | ||
run: echo "${{ secrets.CI_REGISTRY_PASSWORD }}" | docker login -u ${{ secrets.CI_REGISTRY_USER }} --password-stdin ${{ secrets.CI_REGISTRY }} | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t ${{ secrets.CI_REGISTRY_IMAGE }}:${{ github.sha }} -t ${{ secrets.CI_REGISTRY_IMAGE }}:latest -f ./deployments/Dockerfile . | ||
- name: Push Docker image | ||
run: | | ||
docker push ${{ secrets.CI_REGISTRY_IMAGE }}:latest | ||
docker push ${{ secrets.CI_REGISTRY_IMAGE }}:${{ github.sha }} | ||
deploy: | ||
name: Deploy | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to Docker registry | ||
run: echo "${{ secrets.CI_REGISTRY_PASSWORD }}" | docker login -u ${{ secrets.CI_REGISTRY_USER }} --password-stdin ${{ secrets.CI_REGISTRY }} | ||
|
||
- name: Deploy Docker container | ||
run: docker run -d -p 8000:8001 ${{ secrets.CI_REGISTRY_IMAGE }}:latest |
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 @@ | ||
# build environment | ||
FROM node:20.10-alpine as build | ||
WORKDIR /app | ||
COPY .. . | ||
RUN yarn | ||
RUN yarn build | ||
|
||
# production environment | ||
FROM nginx:stable-alpine | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
COPY --from=build /app/deployments/nginx/nginx.conf /etc/nginx/conf.d/default.conf | ||
EXPOSE 80 | ||
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,8 @@ | ||
server { | ||
listen 80; | ||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
try_files $uri $uri/ /index.html =404; | ||
} | ||
} |