This commit is contained in:
mei 2024-11-30 13:56:24 +08:00
parent a4fc0ed9fe
commit 47900a9c2b

View File

@ -1,8 +1,7 @@
# Stage 1: Install dependencies # Stage 1: Install dependencies
FROM node:18-alpine AS builder FROM node:18-alpine AS builder
WORKDIR /app WORKDIR /app
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.17/main" > /etc/apk/repositories && \ RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories
echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.17/community" >> /etc/apk/repositories
RUN apk update RUN apk update
RUN npm config set registry https://registry.npmmirror.com RUN npm config set registry https://registry.npmmirror.com
COPY package*.json ./ COPY package*.json ./
@ -19,8 +18,7 @@ RUN npm run build
FROM node:18-alpine AS runner FROM node:18-alpine AS runner
RUN mkdir -p /app/data && chmod 755 /app/data RUN mkdir -p /app/data && chmod 755 /app/data
WORKDIR /app WORKDIR /app
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.17/main" > /etc/apk/repositories && \ RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories
echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.17/community" >> /etc/apk/repositories
RUN apk update RUN apk update
ENV NODE_ENV Production ENV NODE_ENV Production
COPY --from=builder /app/next.config.js ./ COPY --from=builder /app/next.config.js ./
@ -31,5 +29,5 @@ COPY --from=builder /app/package*.json ./
COPY --from=builder /app/data/shorturl.db ./data COPY --from=builder /app/data/shorturl.db ./data
VOLUME /app/data VOLUME /app/data
# 运行应用 # Run App
CMD ["node", "server.js"] CMD ["node", "server.js"]