Commit 39a0e783 authored by erdnaxe's avatar erdnaxe 🎇

Separate dev and prod docker

parent e3103b1c
......@@ -10,12 +10,14 @@ Vignette est séparée entre un *backend* codé avec Django Rest Framwork, et un
## Environnement de développement
Vignette utilise Docker pour simplifier la mise en route.
Pour avoir un environnement de développement, il suffit de cloner le projet et
de lancer :
Pour avoir un environnement de développement, il faut :
```bash
docker-compose up --build
```
- Cloner le projet,
- Copier example.env en .env et le configurer,
- Lancer :
```bash
docker-compose up --build
```
Pour créer un super-utilisateur :
......@@ -23,3 +25,12 @@ Pour créer un super-utilisateur :
docker-compose exec backend python manage.py createsuperuser
```
## Production
Le fichier `production.yml` redéfinit des paramètres pour rendre le docker
utilisable en production. Cela est encore en stade exprimental !
```bash
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```
FROM python:3.6-alpine
# Django code will be in /usr/src/app/
# During development you should mount the git code there,
# During production you should copy the code in the image.
# Only during development you should mount the git code there
WORKDIR /usr/src/app
COPY . /usr/src/app/
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Install dependencies via pipenv
COPY Pipfile* ./
RUN apk update && apk add gcc musl-dev postgresql-dev
RUN pip install --upgrade pip==18.0
RUN pip install pipenv==2018.7.1
......@@ -20,7 +19,6 @@ RUN pipenv install --deploy --system --dev
EXPOSE 8080
# Set entrypoint : make migrations and collect statics
COPY entrypoint.sh ./
ENTRYPOINT [ "./entrypoint.sh" ]
# Start Django app
......
# Only for dev
version: '3'
services:
frontend:
volumes:
- ./frontend:/home/node/app
- /home/node/app/node_modules
backend:
environment:
# SECURITY WARNING: don't run with debug turned on in production!
- DEBUG=0
volumes:
- ./backend:/usr/src/app
# Still very experimental, please be careful
version: '3'
services:
db:
restart: always
frontend:
restart: always
backend:
environment:
# SECURITY WARNING: don't run with debug turned on in production!
- DEBUG=0
restart: always
# Use for development purposes only
version: '3'
services:
......@@ -12,33 +10,23 @@ services:
- POSTGRES_INITDB_ARGS=--encoding=UTF-8
volumes:
- db_data:/var/lib/postgresql/data
restart: always
frontend:
build: ./frontend
volumes:
- ./frontend:/home/node/app
- /home/node/app/node_modules
ports:
- "8000:3000"
restart: always
backend:
build: ./backend
environment:
# SECURITY WARNING: keep the secret key used in production secret!
- SECRET_KEY=changemeinprod
# SECURITY WARNING: don't run with debug turned on in production!
- DEBUG=1
- SECRET_KEY=${DJANGO_SECRET}
# Pass needed configuration
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
volumes:
- ./backend:/usr/src/app
ports:
- "8080:8080"
depends_on:
- db
restart: always
volumes:
db_data:
......
......@@ -3,4 +3,5 @@
DB_NAME=vignette
DB_USER=vignette
DB_PASSWORD=changeme
DJANGO_SECRET=changemeinprod
FROM node:8-alpine
# Only during development you should mount the git code there
WORKDIR /home/node/app
COPY . /home/node/app/
# Install dependencies via npm
COPY package* ./
RUN npm install --quiet
# Start frontend
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment