-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
60 lines (47 loc) · 1.55 KB
/
Dockerfile.dev
File metadata and controls
60 lines (47 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FROM node:20-alpine AS development
WORKDIR /app
# Install dumb-init for proper signal handling (before copying app files for better layer caching)
RUN apk add --no-cache dumb-init
# Set environment
ENV NODE_ENV=development
ENV NEXT_TELEMETRY_DISABLED=1
# Build args to allow Railway to forward env vars during docker build
ARG DATABASE_URL
ARG NEXT_AUTH_SECRET
ARG NEXTAUTH_URL
ARG NEXT_PUBLIC_APP_URL
ARG REDIS_URL
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_DEFAULT_REGION
ARG AWS_S3_BUCKET_NAME
ARG AWS_ENDPOINT_URL
ARG AWS_S3_MAX_UPLOAD
ENV DATABASE_URL=${DATABASE_URL}
ENV NEXT_AUTH_SECRET=${NEXT_AUTH_SECRET}
ENV NEXTAUTH_URL=${NEXTAUTH_URL}
ENV NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
ENV REDIS_URL=${REDIS_URL}
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}
ENV AWS_S3_BUCKET_NAME=${AWS_S3_BUCKET_NAME}
ENV AWS_ENDPOINT_URL=${AWS_ENDPOINT_URL}
ENV AWS_S3_MAX_UPLOAD=${AWS_S3_MAX_UPLOAD}
# Copy package files first for better layer caching
COPY package.json package-lock.json ./
# Install ALL dependencies (including dev dependencies) for development
RUN npm ci --include=dev && npm cache clean --force
# Copy source code
COPY . .
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Change ownership of the app directory to the non-root user
RUN chown -R nextjs:nodejs /app
EXPOSE 3000
# Switch to non-root user
USER nextjs
# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "run", "dev"]