-
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.
- Loading branch information
Showing
9 changed files
with
111 additions
and
46 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
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,7 +1,61 @@ | ||
FROM oven/bun:alpine | ||
WORKDIR /home/bun/app | ||
COPY package.json bun.lockb ./ | ||
RUN bun install | ||
COPY . . | ||
EXPOSE 3000 | ||
CMD ["bun", "run", "start"] | ||
################### | ||
# BUILD FOR LOCAL DEVELOPMENT | ||
################### | ||
|
||
FROM node:latest As development | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Copy application dependency manifests to the container image. | ||
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available). | ||
# Copying this first prevents re-running npm install on every code change. | ||
COPY --chown=node:node package*.json ./ | ||
|
||
# Install app dependencies using the `npm install` command instead of `npm install` | ||
RUN npm install | ||
|
||
# Bundle app source | ||
COPY --chown=node:node . . | ||
|
||
# Use the node user from the image (instead of the root user) | ||
USER node | ||
|
||
################### | ||
# BUILD FOR PRODUCTION | ||
################### | ||
|
||
FROM node:latest As build | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY --chown=node:node package*.json ./ | ||
|
||
# In order to run `npm run build` we need access to the Nest CLI which is a dev dependency. In the previous development stage we ran `npm install` which installed all dependencies, so we can copy over the node_modules directory from the development image | ||
COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules | ||
|
||
COPY --chown=node:node . . | ||
|
||
# Run the build command which creates the production bundle | ||
RUN npm run build | ||
|
||
# Set NODE_ENV environment variable | ||
ENV NODE_ENV production | ||
|
||
# Running `npm install` removes the existing node_modules directory and passing in --only=production ensures that only the production dependencies are installed. This ensures that the node_modules directory is as optimized as possible | ||
RUN npm install --only=production && npm cache clean --force | ||
|
||
USER node | ||
|
||
################### | ||
# PRODUCTION | ||
################### | ||
|
||
FROM node:latest As production | ||
|
||
# Copy the bundled code from the build stage to the production image | ||
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules | ||
COPY --chown=node:node --from=build /usr/src/app/dist ./dist | ||
|
||
# Start the server using the production build | ||
CMD [ "node", "dist/main.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
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
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
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
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
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
File renamed without changes.