forked from KSP-SpaceDock/SpaceDock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (48 loc) · 2.94 KB
/
Dockerfile
File metadata and controls
61 lines (48 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
FROM ubuntu:14.04
MAINTAINER frikfry@gmail.com # Someone let me know an appropriate email for the project
# Needed to fix pip install of requirements due to strange char encoding issue.
ENV LC_CTYPE C.UTF-8
# Set this to suppress 'debconf: unable to initialize frontend' errors
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get clean
RUN apt-get update
RUN apt-get install -y curl
# This needs to be broken up because curl isn't available at the start and we need curl to install nodejs
RUN curl -sL https://deb.nodesource.com/setup | sudo bash -
# Don't need to apt-get update first because the script above does it for us.
RUN apt-get install -y nodejs redis-server vim supervisor postgresql postgresql-contrib postgresql-client libpq-dev libffi-dev python-pip python-dev python3-dev build-essential
RUN pip install --upgrade pip
RUN pip install virtualenv
# Make our directories
RUN mkdir -p /opt/spacedock
WORKDIR /opt/spacedock
# Install coffee-script
RUN npm install --global coffee-script
# Create our database.
# TODO: Rename from kerbalstuff to spacedock?
RUN /etc/init.d/postgresql start && sudo -u postgres createdb kerbalstuff
# Breaking up the installing of requirements like this so that it gets cached by docker
COPY requirements.txt /opt/spacedock/requirements.txt
RUN virtualenv --python=python3 --no-site-packages /venv/spacedock
RUN . /venv/spacedock/bin/activate && pip install -r requirements.txt
# Add everything else from the project root to the install dir.
COPY . /opt/spacedock
# Setup the config files, if they don't already exist.
RUN test -f /opt/spacedock/config.ini || cp /opt/spacedock/config.ini.example /opt/spacedock/config.ini
RUN test -f /opt/spacedock/alembic.ini || cp /opt/spacedock/alembic.ini.example /opt/spacedock/alembic.ini
# Make postgres trust all localhost connections implicitly.
COPY docker/pb_hba.conf /etc/postgresql/9.3/main/pg_hba.conf
# Make a supervisord process for actually running the commands.
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create the alembic config.
RUN /etc/init.d/postgresql start && \
/venv/spacedock/bin/python -c 'from alembic.config import Config; from alembic import command; alembic_cfg = Config("alembic.ini"); command.stamp(alembic_cfg, "head"); exit()' && \
/venv/spacedock/bin/alembic upgrade head
# Add a default admin user for development.
RUN /etc/init.d/postgresql start && \
/venv/spacedock/bin/python -c 'from KerbalStuff.objects import *; from KerbalStuff.database import db; u = User("admin", "admin@example.com", "development"); u.admin = True; u.confirmation = None; db.add(u); db.commit()'
# Add a default test user for development.
RUN /etc/init.d/postgresql start && \
/venv/spacedock/bin/python -c 'from KerbalStuff.objects import *; from KerbalStuff.database import db; u = User("user", "user@example.com", "development"); u.confirmation = None; db.add(u); db.commit()'
# Start postgres and run the app when the container starts.
CMD ["/usr/bin/supervisord"]