-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#14 本番環境と開発環境で分ける
- Loading branch information
Showing
2 changed files
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
# Use an official Node.js runtime as a parent image | ||
FROM node:18-slim | ||
|
||
# Set build-time argument (default is 'production') | ||
ARG NODE_ENV=production | ||
|
||
# Set the environment variable based on the build argument | ||
ENV NODE_ENV=${NODE_ENV} | ||
|
||
# Set the working directory in the container to /app | ||
WORKDIR /app | ||
|
||
# Copy the package.json and package-lock.json files to the container | ||
COPY package*.json ./ | ||
|
||
# Install the application dependencies | ||
RUN npm install --production | ||
# Install dependencies based on the environment | ||
RUN if [ "$NODE_ENV" = "production" ]; then \ | ||
npm install --production; \ | ||
else \ | ||
npm install; \ | ||
fi | ||
|
||
# Copy the rest of the application code to the container | ||
COPY src/ ./src | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8080 | ||
|
||
# Define environment variable for production | ||
ENV NODE_ENV=production | ||
|
||
# Run the application | ||
CMD ["node", "src/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters