-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompose.yaml
70 lines (62 loc) · 2.4 KB
/
compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# specify the version of docker-compose
version: '3.8'
# define the services to be run
services:
# define the web service for next.js app.
web:
# we use depends_on to specify that service depends on another service
# in this case, we specify that the web depends on the mongo service
# this means that the mongo service will be started before the web service
depends_on:
- mongo
# specify the environment variables for the web service
# these environment variables will be available inside the container
environment:
- MONGODB_URI=${MONGODB_URI}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
- CLOUDINARY_CLOUD_NAME=${CLOUDINARY_CLOUD_NAME}
- CLOUDINARY_API_KEY=${CLOUDINARY_API_KEY}
- CLOUDINARY_API_SECRET=${CLOUDINARY_API_SECRET}
# specify the build context for the web service
# this is the directory where the Dockerfile for the web service is located
build:
context: .
dockerfile: Dockerfile
# specify the ports to expose for the web service
# the first number is the port on the host machine
# the second number is the port inside the container
ports:
- 3000:3000
# this is for docker compose watch mode
# anything mentioned under develop will be watched for changes by docker compose watch
# and it will perform the action mentioned
develop:
# we specify the files to watch for changes
watch:
- path: ./package.json
action: rebuild
- path: ./next.config.js
action: rebuild
- path: ./package-lock.json
action: rebuild
# it'll watch for changes in the frontend directory and sync the changes with the container real time
- path: .
target: /app
action: sync
# define the db service
mongo:
# specify the image to use for the db service from docker hub.
image: mongo
# specify the ports to expose for the db service
ports:
- 27017:27017
# specify the volumes to mount for the db service
# we're mounting the volume named "amazona" inside the container at /data/db directory
# this is done so that the data inside the mongodb container is persisted even if the container is stopped
volumes:
- amazona:/data/db
# define the volumes to be used by the services
volumes:
amazona: