-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
57 lines (44 loc) · 1.28 KB
/
Dockerfile
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
# Stage 1: Build the application
FROM node:lts-alpine as build
# Create app directory
RUN mkdir /app
WORKDIR /app
# Copy necessary files
COPY package.json .
COPY package-lock.json .
COPY next.config.js .
COPY api-server.js .
COPY .env.local .
# Install dependencies and build the app
RUN npm install
RUN npm run build # Use "npm run build" to build the Next.js application
# Copy build artifacts
COPY .next ./.next
COPY public ./public
COPY . .
# Stage 2: Final container
FROM node:lts-alpine
# Set environment variables
ENV NODE_ENV production
ENV API_PORT 3001
# Set working directory
WORKDIR /app
# Copy files from build stage
COPY --from=build /app/package.json .
COPY --from=build /app/package-lock.json .
COPY --from=build /app/next.config.js .
COPY --from=build /app/api-server.js .
COPY --from=build /app/.env.local .
COPY --from=build /app/.next ./.next
COPY --from=build /app/public ./public
# Copy the Google Cloud Service Account JSON file
COPY triplan.json /app/triplan.json
# Set the environment variable to the path of the service account file
ENV GOOGLE_APPLICATION_CREDENTIALS="./triplan.json"
# Install production dependencies
RUN npm install --only=production
# Expose ports
EXPOSE 3000
EXPOSE 3001
# Start the app
CMD ["npm", "run", "dev"] # Use "npm start" for production