| version: '2' |
| |
| # Define services |
| services: |
| # backend service |
| app-server: |
| image: petstore |
| # Configuration for building the docker image for the backend service |
| build: |
| context: ./ # Use an image built from the specified dockerfile. |
| dockerfile: Dockerfile |
| ports: |
| - "5000:5000" # Forward the exposed port 5000 on the container to port 5000 on the host machine |
| restart: always |
| depends_on: |
| - db |
| |
| networks: # Networks to join |
| - backend |
| - frontend |
| |
| # frontend service |
| app-client: |
| build: |
| context: pets # Use an image built from the specified dockerfile. |
| dockerfile: Dockerfile |
| args: |
| REACT_APP_API_BASE_URL: localhost:3000 |
| ports: |
| - "3000:3000" # Map the exposed port 3000 on the container to port 3000 on the host machine |
| restart: always |
| depends_on: |
| - app-server |
| networks: |
| - frontend |
| |
| # Database Service (Apache Derby) |
| db: |
| image: az82/docker-derby |
| ports: |
| - "1527:1527" |
| restart: always |
| |
| networks: |
| - backend |
| |
| # Volumes |
| volumes: |
| db-data: |
| |
| # Networks to be created to facilitate communication between containers |
| networks: |
| backend: |
| frontend: |