Skip to content

Commit e20fca8

Browse files
committed
Docker compose
1 parent fbb3076 commit e20fca8

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

docker-compose.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
2+
3+
version: '3.3'
4+
5+
# Define services
6+
services:
7+
# App backend service
8+
app-server:
9+
# Configuration for building the docker image for the backend service
10+
build:
11+
context: polling-app-server # Use an image built from the specified dockerfile in the `polling-app-server` directory.
12+
dockerfile: Dockerfile
13+
ports:
14+
- "8080:8080" # Forward the exposed port 8080 on the container to port 8080 on the host machine
15+
restart: always
16+
depends_on:
17+
- db # This service depends on mysql. Start that first.
18+
environment: # Pass environment variables to the service
19+
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/polls?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
20+
SPRING_DATASOURCE_USERNAME: callicoder
21+
SPRING_DATASOURCE_PASSWORD: callicoder
22+
networks: # Networks to join (Services on the same network can communicate with each other using their name)
23+
- backend
24+
- frontend
25+
26+
# Frontend Service
27+
app-client:
28+
build:
29+
context: polling-app-client # Use an image built from the specified dockerfile in the `polling-app-client` directory.
30+
dockerfile: Dockerfile
31+
ports:
32+
- "9090:80" # Forward the exposed port 80 on the container to port 80 on the host machine
33+
restart: always
34+
depends_on:
35+
- app-server
36+
networks:
37+
- frontend
38+
39+
# Database Service (Mysql)
40+
db:
41+
image: mysql:5.7
42+
ports:
43+
- "3306:3306"
44+
restart: always
45+
environment:
46+
MYSQL_DATABASE: polls
47+
MYSQL_USER: callicoder
48+
MYSQL_PASSWORD: callicoder
49+
MYSQL_ROOT_PASSWORD: root
50+
volumes:
51+
- db-data:/var/lib/mysql
52+
networks:
53+
- backend
54+
55+
# Volumes
56+
volumes:
57+
db-data:
58+
59+
# Networks to be created to facilitate communication between containers
60+
networks:
61+
backend:
62+
frontend:

0 commit comments

Comments
 (0)