Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
docs
dist
.vscode
.idea
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SERVICE_NAME=hinghwa-dict-web
BACKEND_URL=https://api.pxm.edialect.top # 代码里暂不支持

# Traefik Only
PORT=80
HOST_ADDRESS=pxm.edialect.top
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:14-alpine AS build
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json yarn.lock ./
ENV NODE_ENV=production
RUN yarn install --frozen-lockfile --production=false
COPY . .
RUN yarn build

FROM nginx:stable-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY scripts/replace_api_prod.sh /
RUN chmod +x /replace_api_prod.sh
COPY --from=build /usr/src/app/dist /usr/share/nginx/html

CMD ["sh", "/replace_api_prod.sh"]
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
hinghwa-dict-web:
image: "${SERVICE_NAME}"
build: .
container_name: "${SERVICE_NAME}"
environment:
VITE_BACKEND_URL: "${BACKEND_URL}"
labels:
- "traefik.http.routers.${SERVICE_NAME}.rule=${HOST_ADDRESS}"
- "traefik.http.services.${SERVICE_NAME}.loadbalancer.server.port=${PORT:-80}"
- "traefik.http.routers.${SERVICE_NAME}.entrypoints=websecure"
- "traefik.http.routers.${SERVICE_NAME}.tls=true"
- "traefik.http.routers.${SERVICE_NAME}.middlewares=${SERVICE_NAME}-compress"
- "traefik.http.middlewares.${SERVICE_NAME}-compress.compress=true"
networks:
- traefik-global-proxy

networks:
traefik-global-proxy:
external: true
28 changes: 28 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {
listen 80;
server_name localhost;

location /assets/ {
alias /usr/share/nginx/html/assets/;
}

location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache";
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~* \.(?:css|js|ico)$ {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;

expires 15d;
add_header Pragma public;
add_header Cache-Control "public";
}
}
Loading