Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dockerfile
- #!/bin/bash
- FROM python:3.6-alpine
- ENV PYTHONDONTWRITEBYTECODE 1
- ENV PYTHONUNBUFFERED 1
- RUN mkdir /usr/src/app
- WORKDIR /usr/src/app
- RUN apk update \
- && apk add --virtual build-deps gcc python3-dev musl-dev libc-dev \
- && apk add postgresql-dev \
- && pip install psycopg2 \
- && apk del build-deps
- RUN pip install --upgrade pip
- RUN pip install pipenv
- COPY ./Pipfile /usr/src/app
- RUN pipenv install --skip-lock --system --dev
- COPY ./entrypoint.sh /usr/src/app
- RUN chmod +x /usr/src/app/entrypoint.sh
- COPY . /usr/src/app
- ENTRYPOINT [ "/usr/src/app/entrypoint.sh" ]
- # **** docker-compose.yml *******
- version: '3'
- services:
- web:
- build: .
- command: python manage.py runserver 0.0.0.0:8000
- volumes:
- - .:/code
- - static_volume:/code/staticfiles
- expose:
- - 8000
- environment:
- - SQL_ENGINE=django.db.backends.postgresql
- - SQL_DATABASE=postgres
- - SQL_USER=postgres
- - SQL_PASSWORD=postgres
- - SQL_HOST=db
- - SQL_PORT=5432
- - DATABASE=postgres
- depends_on:
- - db
- db:
- image: postgres:10.5-alpine
- nginx:
- build: ./nginx
- volumes:
- - static_volume:/usr/src/app/staticfiles
- ports:
- - 1337:80
- depends_on:
- - web
- volumes:
- static_volume:
- # ********** entrypoint.sh **********
- #!/bin/sh
- if [ "$DATABASE" = "postgres" ]
- then
- echo "Esperando por postgres..."
- while ! nc -z $SQL_HOST $SQL_PORT; do
- sleep 0.1
- done
- echo "PostgreSQL started"
- fi
- python manage.py flush --noinput
- python manage.py makemigrations
- python manage.py migrate
- python manage.py collectstatic --noinput
- exec "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement