I’m having problems containerizing my Angular micro frontend setup with Nx workspace. Been working on this for days but can’t get it running properly in Docker.
My Current Setup
- Using Angular with Nx monorepo
- Module Federation for micro frontend communication
- One main shell app and multiple remote applications
What I’ve Attempted
First Try: Containerized just the shell application alone. The container starts fine but when I open the browser I get ERR_EMPTY_RESPONSE error.
Second Try: Used Docker Compose to spin up all remote applications first, then the shell. All containers start without errors but same browser issue persists.
Current Docker Configuration
Here’s my container setup for each application:
# Build stage
FROM node:16-alpine AS build
# Add build tools for native dependencies
RUN apk add python3 make g++
WORKDIR /workspace
# Copy configuration files
COPY package*.json ./
COPY nx.json ./
COPY tsconfig*.json ./
COPY decorate-angular-cli.js ./
# Install packages
RUN npm install --force && npm run build
# Copy application source
COPY . .
CMD ["npm", "run", "start"]
Docker Compose Setup
version: '3.8'
services:
shell-app:
build: .
ports:
- "4200:4200"
depends_on:
- mfe-one
- mfe-two
- mfe-three
networks:
- frontend-network
mfe-one:
build: .
ports:
- "4300:4300"
networks:
- frontend-network
mfe-two:
build: .
ports:
- "4400:4400"
networks:
- frontend-network
mfe-three:
build: .
ports:
- "4500:4500"
networks:
- frontend-network
networks:
frontend-network:
driver: bridge
Main Questions
- Is this Docker setup appropriate for Angular micro frontends?
- How do I make sure remote modules load correctly in containers?
- Any specific considerations for Webpack 5 Module Federation in Docker?