Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/scripts/mailchimp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Dockerfile → Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ COPY . .
# Expose the port for development (if needed)
EXPOSE 3000

# Set environment variables for development (optional)
# Set environment variables for development
ENV NODE_ENV=development

CMD ["npm", "run", "dev"]

# Build command -> docker build -f Dockerfile.dev --build-arg NODE_ENV=development -t app-dev .
Copy link
Member

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?

31 changes: 31 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM node:18-alpine AS build
Copy link
Member

Choose a reason for hiding this comment

The 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 .
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not rendering in a proper way
Check the preview in online md file convertor

```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.

Expand Down
Loading