Skip to content
Snippets Groups Projects
Commit b61ac547 authored by jan.bednarik's avatar jan.bednarik
Browse files

Dockerization update

parent d233d75f
No related branches found
No related tags found
No related merge requests found
.git
.venv
.envrc
# Use an official Python runtime as a parent image
FROM python:3.7
LABEL maintainer="hello@wagtail.io"
FROM python:3.8-slim
# Set environment varibles
ENV PYTHONUNBUFFERED 1
ENV DJANGO_ENV dev
RUN mkdir /app
WORKDIR /app
COPY ./requirements.txt /code/requirements.txt
RUN pip install --upgrade pip
# Install any needed packages specified in requirements.txt
RUN pip install -r /code/requirements.txt
RUN pip install gunicorn
COPY requirements requirements/
RUN pip install -r requirements/base.txt -r requirements/production.txt
# Copy the current directory contents into the container at /code/
COPY . /code/
# Set the working directory to /code/
WORKDIR /code/
COPY . .
RUN python manage.py migrate
RUN useradd app
RUN chown -R app /app
USER app
RUN useradd wagtail
RUN chown -R wagtail /code
USER wagtail
ENV DJANGO_SETTINGS_MODULE "majak.settings.production"
EXPOSE 8000
CMD exec gunicorn majak.wsgi:application --bind 0.0.0.0:8000 --workers 3
CMD ["bash", "run.sh"]
......@@ -4,7 +4,9 @@ Maják je CMS pro Pirátské weby. Postavený je na [Wagtail](https://wagtail.io
## Vývoj
Pro vývoj je definován pomocný `Makefile` pro časté akce.
Pro vývoj je definován pomocný `Makefile` pro časté akce. Pro nápovědu zavolej:
$ make help
### Lokální instalace a spuštění
......@@ -69,11 +71,11 @@ Při změně modelů vygeneruj migrace pomocí:
#### Spuštění development serveru
Django development server na portu `8003` se spustí příkazem:
Django development server na portu `8006` se spustí příkazem:
$ make run
Poté můžete otevřít web na adrese [http://localhost:8003](http://localhost:8003)
Poté můžete otevřít web na adrese [http://localhost:8006](http://localhost:8006)
#### Django shell
......@@ -114,5 +116,6 @@ K upgrade se používají [pip-tools](https://github.com/jazzband/pip-tools) (`p
$ cd requirements/
$ pip-compile -U base.in
$ pip-compile -U production.in
Tím se vygenerují `base.txt`.
Tím se vygenerují `base.txt` a `production.txt`.
bind = "0.0.0.0:8000"
accesslog = "-"
workers = 4
max_requests = 1000
max_requests_jitter = 10
......@@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "majak.settings.dev")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "majak.settings.production")
application = get_wsgi_application()
gunicorn
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile production.in
#
gunicorn==20.0.4 # via -r production.in
# The following packages are considered to be unsafe in a requirements file:
# setuptools
run.sh 0 → 100644
#!/bin/bash
# exit on error
set -e
# migrate database
python manage.py migrate
# start webserver
exec gunicorn -c gunicorn.conf.py majak.wsgi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment