Skip to content

Commit

Permalink
Dockerize microfrontends
Browse files Browse the repository at this point in the history
  • Loading branch information
blaz-cerpnjak committed Apr 17, 2024
1 parent 94d7763 commit f315dac
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 2 deletions.
12 changes: 12 additions & 0 deletions WEB_Microfrontends/basket/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:21-alpine
WORKDIR /app

COPY package.json /app

RUN npm install

COPY . /app

EXPOSE 3002

CMD ["npm", "start"]
3 changes: 3 additions & 0 deletions WEB_Microfrontends/home/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

.env.production
.env.development

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
12 changes: 12 additions & 0 deletions WEB_Microfrontends/home/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:21-alpine
WORKDIR /app

COPY package.json /app

RUN npm install

COPY . /app

EXPOSE 3000

CMD ["npm", "start"]
2 changes: 1 addition & 1 deletion WEB_Microfrontends/home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "home",
"version": "1.0.0",
"scripts": {
"build": "webpack --mode production",
"build": "webpack --mode production --no-cache",
"build:dev": "webpack --mode development",
"build:start": "cd dist && PORT=3000 npx serve",
"start": "webpack serve --open --mode development",
Expand Down
2 changes: 1 addition & 1 deletion WEB_Microfrontends/home/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = (_, argv) => ({
allowedHosts: "all",
proxy: {
"/api/v1": {
target: "http://localhost:8080/api/v1",
target: "http://web-api-gateway:8080/api/v1",
changeOrigin: true,
secure: false,
pathRewrite: { "^/api/v1": "" },
Expand Down
12 changes: 12 additions & 0 deletions WEB_Microfrontends/orders/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:21-alpine
WORKDIR /app

COPY package.json /app

RUN npm install

COPY . /app

EXPOSE 3001

CMD ["npm", "start"]
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,42 @@ services:
networks:
- native

# Orders Microfrontend
orders-web-app:
depends_on:
- web-api-gateway
build:
context: ./WEB_Microfrontends/orders
dockerfile: Dockerfile
ports:
- "3001:3001"
networks:
- native

# Basket Microfrontend
basket-web-app:
depends_on:
- orders-web-app
build:
context: ./WEB_Microfrontends/basket
dockerfile: Dockerfile
ports:
- "3002:3002"
networks:
- native

# Home Microfrontend
home-web-app:
depends_on:
- basket-web-app
build:
context: ./WEB_Microfrontends/home
dockerfile: Dockerfile
ports:
- "3000:3000"
networks:
- native

networks:
native:
name: native-network
Expand Down

0 comments on commit f315dac

Please sign in to comment.