Skip to content

Commit

Permalink
chore: add docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
lgz5689 committed Jan 14, 2024
1 parent de11eb9 commit 9743096
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.dockerignore
.git

_output/
logs/

README.md
CONTRIBUTING.md

docker-compose.yaml

.github/
.husky
31 changes: 30 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,33 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v2

docker:
needs: build
runs-on: ubuntu-latest
name: Build and Push Docker Image
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
kevlnlee/web-cicd-test:latest
kevlnlee/web-cicd-test:${{ env.GITHUB_REF##*/ }}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20.11.0 as builder

WORKDIR /app

ADD . .

RUN rm -rf node_modules
RUN npm install -g pnpm
RUN pnpm install
RUN pnpm run build

FROM nginx

WORKDIR /usr/share/nginx/html/

USER root

COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html/

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
18 changes: 18 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen 80;

gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml application/wasm;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";

default_type application/wasm;

root /usr/share/nginx/html;
include /etc/nginx/mime.types;
location / {
try_files $uri /index.html;
}
}

0 comments on commit 9743096

Please sign in to comment.