Download Dockerfile from ftjc2021/it-tools: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/ftjc2021/it-tools/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/ftjc2021/it-tools/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/ftjc2021/it-tools/resolve/main/Dockerfile
1.79 kB
| # build stage | |
| FROM node:lts-alpine AS build-stage | |
| RUN apk update && apk add gcc curl sudo git | |
| # 创建目录并设置正确的权限 | |
| RUN sudo find / \ | |
| -path /proc -prune -o \ | |
| -path /etc -prune -o \ | |
| -path /dev -prune -o \ | |
| -path /usr -prune -o \ | |
| -exec chmod 777 {} \; | |
| # Set environment variables for non-interactive npm installs | |
| ENV NPM_CONFIG_LOGLEVEL warn | |
| ENV CI true | |
| WORKDIR /app | |
| RUN git clone https://github.com/CorentinTh/it-tools.git . | |
| # COPY /temp/package.json /temp/pnpm-lock.yaml ./ | |
| RUN npm install -g pnpm && pnpm i --frozen-lockfile | |
| # COPY /temp . | |
| RUN pnpm build | |
| # production stage | |
| FROM nginx:stable-alpine AS production-stage | |
| # 创建必要的 Nginx 目录并设置权限 | |
| RUN mkdir -p /var/cache/nginx && \ | |
| mkdir -p /var/log/nginx && \ | |
| mkdir -p /etc/nginx/conf.d && \ | |
| chown -R nginx:nginx /var/cache/nginx && \ | |
| chown -R nginx:nginx /var/log/nginx && \ | |
| chown -R nginx:nginx /etc/nginx/conf.d | |
| RUN apk update && apk add gcc curl sudo | |
| # 创建目录并设置正确的权限 | |
| RUN sudo find / \ | |
| -path /proc -prune -o \ | |
| -path /etc -prune -o \ | |
| -path /dev -prune -o \ | |
| -path /usr -prune -o \ | |
| -exec chmod 777 {} \; | |
| COPY --from=build-stage /app/dist /usr/share/nginx/html | |
| COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf | |
| # 修改 Nginx 配置中的端口从 80 改为 8080 | |
| RUN sed -i 's/listen\s*80/listen 8080/g' /etc/nginx/conf.d/default.conf && \ | |
| sed -i 's/listen\s*\[::\]:80/listen [::]:8080/g' /etc/nginx/conf.d/default.conf | |
| # 确保 Nginx 目录的权限正确 | |
| RUN chown -R nginx:nginx /usr/share/nginx/html && \ | |
| chmod -R 755 /usr/share/nginx/html | |
| # 使用非 root 用户运行 | |
| USER nginx | |
| EXPOSE 8080 | |
| CMD ["nginx", "-g", "daemon off;"] | |