Hey !
I just finished to dockerize my app. I think that can be useful so I share it with you. Please feel free to comment if my docker conf could be improved
docker-compose.yml
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.16.2
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
managementApiSecret: XXX
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: XXX
migrations: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: XXX
volumes:
- mysql:/var/lib/mysql
ports:
- "3306:3306"
web:
build: .
restart: always
ports:
- "4000:4000"
depends_on:
- "prisma"
command: ./wait-for-it.sh prisma:4466 -- bash -c "prisma deploy && npm start"
environment:
PRISMA_ENDPOINT: http://prisma:4466
PRISMA_SECRET: XXX
APP_SECRET: XXX
volumes:
mysql:
Dockerfile
FROM node:8.10
WORKDIR /code
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 4000
I forced prima to use 4000 port :
server.start({ port: 4000 }, ({ port }) => winston.info(
`Server started, listening on port ${port} for incoming requests. Watch it !`,
));
And here
db: new Prisma({
endpoint: 'http://prisma:4466', // you have to use prisma: instead of localhost: in docker env
...
}),
If you want to develop on your docker, just replace npm start by nodemon for example in the docker-compose.yml and use this trick on mac http://www.fredlackey.com/develop-on-docker-without-slow-dependencies/ to develop without wait a long time at each refresh.
Hope that helps !