Skip to content

Commit

Permalink
updated Dockerfile to be multi-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycook123 committed Oct 12, 2023
1 parent 3fa4167 commit ec15424
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FROM node:16.15-alpine AS builder
USER node
RUN mkdir -p /home/node/stocks-app
WORKDIR /home/node/stocks-app
COPY --chown=node . .
RUN yarn install
RUN yarn build

FROM nginx:1.20

LABEL io.k8s.description="Platform for serving static HTML files" \
io.k8s.display-name="Nginx 1.20"

COPY build /usr/share/nginx/html/
COPY --from=builder /home/node/stocks-app/build /usr/share/nginx/html/
COPY .env /usr/share/nginx/html/
COPY env-config.js /usr/share/nginx/html/

Expand Down
22 changes: 5 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,23 @@ Microservices Stock Application

## Build Instructions

1. Download dependencies:
1. Build the `cloudacademydevops/stocks-app` frontend UI container image. Run the multi-stage Dockerfile:

```
yarn install
```
2. Build UI package:
```
yarn build
```
3. Build UI container image:
```
docker build -t cloudacademydevops/stocks-app:v2 .
docker build -t cloudacademydevops/stocks-app .
```
## Container Launch Instructions
The UI container image can be launched using the following commands:
- Starts the container instance with Nginx proxy_pass enabled for the `/api/stocks/csv` path, useful for demonstrating service discovery on downstream components etc:
- Starts the container instance with Nginx `proxy_pass` enabled for the `/api/stocks/csv` path, useful for demonstrating service discovery on downstream components etc:
```
docker run --rm -it --name stock-app --env NGINX_APP_APIHOSTPORT=api.cloudacademy.terraform.local:8080 -p 8080:8080 cloudacademydevops/stocks-app:v2
docker run --rm -it --name stock-app --env NGINX_APP_APIHOSTPORT=api.10.0.0.100.nip.io:8000 --env NGINX_DNS_RESOLVER=8.8.8.8 -p 8080:8080 cloudacademydevops/stocks-app
```
- Starts the container instance **without** the Nginx proxy_pass enabled for the `/api/stocks/csv` path:
- Starts the container instance **without** the Nginx `proxy_pass` enabled for the `/api/stocks/csv` path:
```
docker run --rm -it --name stock-app -p 8080:8080 cloudacademydevops/stocks-app:v2
Expand Down

0 comments on commit ec15424

Please sign in to comment.