diff --git a/.gitignore b/.gitignore index 30add79..a9e1c0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Ignore docker-compose +docker-compose.yml + # Virtualenv/Common /bin/ /build/ diff --git a/Dockerfile b/Dockerfile index 71c2187..84f11d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,3 @@ COPY . /app RUN pip install pipenv RUN pipenv install --three --system - -RUN python3 manage.py collectstatic --noinput - -VOLUME /app/static/media - diff --git a/docker-compose.example.yml b/docker-compose.example.yml new file mode 100644 index 0000000..b1d2be7 --- /dev/null +++ b/docker-compose.example.yml @@ -0,0 +1,18 @@ +version: '3' + +services: + web: + build: . + working_dir: /app + command: > + bash -c "python manage.py migrate + && python3 manage.py collectstatic --noinput + && gunicorn pinry.wsgi:application -b 0.0.0.0:8000 --timeout 30 --log-file - " + ports: + - "127.0.0.1:2048:8000" + environment: + - SECRET_KEY=CHANGE-ME + user: ${CURRENT_UID} + volumes: + - .:/app + restart: always diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index c7a7b27..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: '3' - -services: - db: - image: postgres - web: - build: . - command: gunicorn pinry.wsgi:application -b 0.0.0.0:80 --timeout 30 --log-file - - ports: - - "80:80" - depends_on: - - db - environment: - - SECRET_KEY=CHANGE-ME - volumes: - - media:/app/static/media - -volumes: - media: diff --git a/start_docker_with_current_user.sh b/start_docker_with_current_user.sh new file mode 100755 index 0000000..90dbfe5 --- /dev/null +++ b/start_docker_with_current_user.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +CURRENT_UID=$(id -u):$(id -g) sudo docker-compose up ${@}