Skip to content

Instantly share code, notes, and snippets.

@image72
Created August 2, 2024 01:49
Show Gist options
  • Save image72/035c129ae706e9b96c5c9dd4a02843e7 to your computer and use it in GitHub Desktop.
Save image72/035c129ae706e9b96c5c9dd4a02843e7 to your computer and use it in GitHub Desktop.
normal nodejs project with nginx.
FROM node:20-alpine as build-stage
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV HTTP_PROXY=$HTTP_PROXY
ENV HTTPS_PROXY=$HTTPS_PROXY
WORKDIR /usr/src/app
COPY . .
RUN npm -g install pnpm@latest && pnpm config set registry=https://registry.npmmirror.com && pnpm install && npm run build
FROM nginx:stable-alpine
COPY --from=build-stage /usr/src/app/dist /usr/share/nginx/html
EXPOSE 80
RUN cat > /etc/nginx/conf.d/default.conf <<EOF
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
EOF
CMD ["nginx", "-g", "daemon off;"]
# docker buildx build \
# --platform linux/amd64 \
# --build-arg HTTP_PROXY=http://192.168.1.13:7890 \
# --build-arg HTTPS_PROXY=http://192.168.1.13:7890 \
# -t sdh-site:latest .
# docker run -it --rm -e NODE_ENV=production -p 8085:80 sdh-site:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment