-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: made the Docker file Multistaged #3237
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM node:18-alpine AS build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide the link for this code file from where you have taken inspiration |
||
|
||
WORKDIR /async | ||
|
||
# Install all dependencies | ||
COPY package.json package-lock.json ./ | ||
RUN npm install | ||
|
||
# Copy the rest of the application files | ||
COPY . . | ||
|
||
# Production Stage | ||
FROM node:18-alpine | ||
|
||
WORKDIR /async | ||
|
||
# Install production dependencies only | ||
COPY package.json package-lock.json ./ | ||
RUN npm install --only=production | ||
|
||
# Copy built files from the build stage | ||
COPY --from=build /async . | ||
|
||
EXPOSE 3000 | ||
|
||
# Set environment variables for production | ||
ENV NODE_ENV=production | ||
|
||
CMD ["npm", "run", "start"] | ||
|
||
# Build command -> docker build -f Dockerfile.prod --build-arg NODE_ENV=production -t app-prod . |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,14 +123,25 @@ Generated files of the storybook go to the `storybook-static` folder. | |
After cloning repository to your local, perform the following steps from the root of the repository. | ||
|
||
#### Steps: | ||
1. Build the Docker image: | ||
1. Development Setup with Docker: | ||
1. Build the Docker image: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not rendering in a proper way |
||
```bash | ||
docker build -t asyncapi-website .` | ||
docker build -f Dockerfile.dev --build-arg NODE_ENV=development -t app-dev . | ||
``` | ||
2. Start the container: | ||
2. Start the container: | ||
```bash | ||
docker run --rm -it -v "$PWD":/async -p 3000:3000 asyncapi-website | ||
docker run --rm -it -v "$PWD":/async -p 3000:3000 app-dev | ||
``` | ||
2. Production Setup with Docker | ||
1. Build the Docker image: | ||
```bash | ||
docker build -f Dockerfile.prod --build-arg NODE_ENV=production -t app-prod . | ||
``` | ||
2. Start the container: | ||
```bash | ||
docker run --rm -p 3000:3000 app-prod | ||
``` | ||
|
||
|
||
Now you're running AsyncAPI website in a development mode. Container is mapped with your local copy of the website. Whenever you make changes to the code, the website will refresh and changes visible in localhost:3000. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line of code signify?