other
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -7,10 +7,16 @@ RUN npm install --force
|
||||
|
||||
COPY . .
|
||||
|
||||
# Install git, get commit hash
|
||||
RUN apk add --no-cache git \
|
||||
&& git rev-parse --short HEAD > /app/git_commit_sha
|
||||
|
||||
ENV NEXT_PUBLIC_API_URL=/api
|
||||
|
||||
# Build the Next.js application
|
||||
RUN npm run build
|
||||
# The environment variable will be available during build if needed
|
||||
# ENV GIT_COMMIT_SHA=$(cat /app/git_commit_sha)
|
||||
RUN echo "Building with GIT_COMMIT_SHA=$(cat /app/git_commit_sha)" && npm run build
|
||||
|
||||
# ---- Production Stage ----
|
||||
FROM node:18-alpine AS runner
|
||||
@@ -25,12 +31,18 @@ COPY --from=builder /app/package.json /app/package-lock.json ./
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Copy commit hash file from builder stage
|
||||
COPY --from=builder /app/git_commit_sha /app/git_commit_sha
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_PUBLIC_API_URL=/api
|
||||
ENV SERVER_API_URL=https://internal-api.inboxi.ng/api
|
||||
|
||||
# Set GIT_COMMIT_SHA environment variable in the final image by reading the file
|
||||
ENV GIT_COMMIT_SHA="$(cat /app/git_commit_sha)"
|
||||
|
||||
|
||||
# Start Next.js server
|
||||
CMD ["npm", "run", "start"]
|
||||
Reference in New Issue
Block a user