Skip to content

Instantly share code, notes, and snippets.

@meisterluk
Last active July 26, 2019 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meisterluk/7af07f18d6146cc9fc1858d3f0436a0f to your computer and use it in GitHub Desktop.
Save meisterluk/7af07f18d6146cc9fc1858d3f0436a0f to your computer and use it in GitHub Desktop.
Get pretalx 1.0.3 run in one development docker container
FROM debian:buster-20190708
RUN apt-get update && apt-get upgrade
RUN apt install -y python3-pip nginx postgresql redis sudo
RUN adduser root sudo
# corresponds to “Step 0: Prerequisites”
RUN adduser pretalx --disabled-password --home /var/pretalx --system --gecos 'pretalx user account'
# corresponds to “adduser pretalx --disabled-password --home /var/pretalx” of “Step 1: Unix user“
RUN apt-get install -y build-essential libssl-dev python3-dev gettext
# corresponds to “build-essential … gettext” of “Step 3: Package dependencies”
USER pretalx
RUN pip3 install --user -U pip setuptools wheel gunicorn psycopg2-binary
RUN pip3 install --user -U pretalx[redis]
USER root
RUN mkdir -p /var/pretalx/data/media
RUN chown -R pretalx: /var/pretalx/data
# corresponds to “pip install --user -U pip setuptools wheel gunicorn”,
# “pip install --user -U psycopg2-binary”, “pip install --user -U pretalx”
# and “mkdir -p /var/pretalx/data/media” of “Step 5: Installation”
# covers parts of Step 2, Step 4 and Step 5
COPY "setup.sh" "/home/pretalx/setup.sh"
RUN chown pretalx "/home/pretalx/setup.sh"
RUN chmod "a+x" "/home/pretalx/setup.sh"
WORKDIR /home/pretalx
#!/bin/bash
# … put the two files above in the same directory. Then call the following commands:
docker build -t pretalx .
docker run -it --rm -p 8080:8345 pretalx
# follow the instructions printed by the Docker container "setup.sh" script
#!/bin/bash
set -v -e
service postgresql start
## Step 2
# corresponds to “sudo -u postgres createuser pretalx -P”
# and “sudo -u postgres createdb -O pretalx pretalx”
sudo -u postgres createuser pretalx --no-login
sudo -u postgres createdb -O pretalx pretalxdb
sudo -u postgres psql pretalxdb -c 'ALTER ROLE "pretalx" WITH LOGIN'
## Step 4
# corresponds to “mkdir /etc/pretalx”, “touch /etc/pretalx/pretalx.cfg”
# “chown -R pretalx:pretalx /etc/pretalx/” and ”chmod 0600 /etc/pretalx/pretalx.cfg”
mkdir /etc/pretalx
touch /etc/pretalx/pretalx.cfg
chown -R pretalx /etc/pretalx/
chmod 0600 /etc/pretalx/pretalx.cfg
# corresponds to filling “/etc/pretalx/pretalx.cfg”
cat >> /etc/pretalx/pretalx.cfg <<EOF
[filesystem]
data = /var/pretalx/data
media = /var/pretalx/data/media
logs = /var/pretalx/data/logs
[site]
debug = True
url = http://localhost:8345/
[database]
backend = postgresql
name = pretalxdb
user = pretalx
host = /var/run/postgresql
[mail]
from = admin@localhost
host = localhost
port = 25
user = admin
password = something
tls = False
ssl = False
EOF
## Step 5
# corresponds to “python -m pretalx migrate” and “python -m pretalx rebuild”
sudo -u pretalx python3 -m pretalx migrate
sudo -u pretalx python3 -m pretalx rebuild || true # damn, you django_compressor
## Step 6
# corresponds to filling “/etc/systemd/system/pretalx-web.service”
cat >> /etc/systemd/system/pretalx-web.service <<EOF
[Unit]
Description=pretalx web service
After=network.target
[Service]
User=pretalx
Group=pretalx
WorkingDirectory=/var/pretalx/.local/lib/python3.6/site-packages/pretalx
ExecStart=/var/pretalx/.local/bin/gunicorn pretalx.wsgi \
--name pretalx --workers 4 \
--max-requests 1200 --max-requests-jitter 50 \
--log-level=info --bind=127.0.0.1:8345
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
set +v
echo -e "\n\nDon't forget to run the following commands now:\n"
echo "sudo -u pretalx python3 -m pretalx init" # Step 5
## assumes systemd-booted system
#echo "systemctl daemon-reload"
#echo "systemctl enable pretalx-web pretalx-worker"
#echo "systemctl start pretalx-web pretalx-worker"
## else
echo "sudo -u pretalx /var/pretalx/.local/bin/gunicorn pretalx.wsgi --name pretalx --workers 4 --max-requests 1200 --max-requests-jitter 50 --log-level=info --bind=0.0.0.0:8345 --capture-output --error-logfile /var/pretalx/data/logs/std.log --access-logformat /var/pretalx/data/logs/access.log --log-level debug"
echo "then visit http://127.0.0.1:8080/orga/event/new/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment