Skip to content

Commit

Permalink
chore:
Browse files Browse the repository at this point in the history
  • Loading branch information
이은상 committed Dec 26, 2024
1 parent e559287 commit c9b6ede
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions 7_auth/7_1_express_js/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
# Step 1: Use an official Node.js image as the base image
FROM node:16 AS build

# Step 2: Set build-time arguments for CLIENT_ID and CLIENT_SECRET
ARG CLIENT_ID
ARG CLIENT_SECRET
FROM node:18 AS build

# Step 3: Set the working directory in the container
WORKDIR /app

# Step 4: Copy package.json and package-lock.json (if available)
COPY package*.json ./

# Step 5: Install the dependencies (both production and dev)
# Step 5: Install dependencies (both production and dev)
RUN npm install

# Step 6: Copy the entire application source code into the container
COPY . .

# Step 7: Set environment variables using the injected ARG values
ENV CLIENT_ID=${CLIENT_ID}
ENV CLIENT_SECRET=${CLIENT_SECRET}

# Step 8: Build the TypeScript code
# Step 7: Build the TypeScript code
RUN npm run build

# Step 9: Use a smaller production image for runtime (optional)
FROM node:16-slim
# Step 8: Now use a smaller production image for runtime (optional)
FROM node:18-slim

# Step 10: Set the working directory in the container
# Step 9: Set the working directory in the container
WORKDIR /app

# Step 10: Set environment variables for CLIENT_ID and CLIENT_SECRET for runtime
# These will be passed during build and made available in the final image
ARG CLIENT_ID
ARG CLIENT_SECRET
ENV CLIENT_ID=${CLIENT_ID}
ENV CLIENT_SECRET=${CLIENT_SECRET}

# Step 11: Copy the built files from the build stage
COPY --from=build /app /app

Expand All @@ -40,4 +39,4 @@ RUN npm install --only=production
EXPOSE 3000

# Step 14: Start the application
CMD ["npm", "start"]
CMD ["npm", "start"]

0 comments on commit c9b6ede

Please sign in to comment.