forked from metabrainz/listenbrainz-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
90 lines (71 loc) · 3.27 KB
/
Dockerfile.prod
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
FROM metabrainz/python:3.6
ARG deploy_env
ENV DOCKERIZE_VERSION v0.2.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
git \
libpq-dev \
libffi-dev \
libssl-dev \
redis-tools \
pxz \
rsync \
&& rm -rf /var/lib/apt/lists/*
# PostgreSQL client
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
ENV PG_MAJOR 9.5
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client-$PG_MAJOR \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install uWSGI==2.0.13.1
RUN mkdir /code
WORKDIR /code
# MessyBrainz
RUN git clone https://github.com/metabrainz/messybrainz-server.git messybrainz
WORKDIR /code/messybrainz
RUN pip3 install -r requirements.txt
RUN python3 setup.py install
# ListenBrainz
WORKDIR /code/listenbrainz
COPY ./requirements.txt .
RUN pip3 install -r requirements.txt
RUN pip3 install setuptools==36.0.1
COPY . /code/listenbrainz
WORKDIR /code/listenbrainz
# Sometimes the local copy of config.py[c] gets in the way. Better nuke it to not conflict.
RUN rm -f /code/listenbrainz/listenbrainz/config.py /code/listenbrainz/listenbrainz/config.pyc
# create a user named listenbrainz for cron jobs and storing dump file backups
RUN useradd --create-home --shell /bin/bash listenbrainz
RUN mkdir /home/listenbrainz/backup /home/listenbrainz/ftp
RUN chown -R listenbrainz:listenbrainz /home/listenbrainz/backup /home/listenbrainz/ftp
# Add cron jobs
ADD docker/crontab /etc/cron.d/lb-crontab
RUN chmod 0644 /etc/cron.d/lb-crontab && crontab -u listenbrainz /etc/cron.d/lb-crontab
RUN touch /var/log/stats.log /var/log/dump_create.log && chown listenbrainz:listenbrainz /var/log/stats.log /var/log/dump_create.log
# Make sure the cron service doesn't start automagically
# http://smarden.org/runit/runsv.8.html
RUN touch /etc/service/cron/down
# Node
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g less@2.7.2
RUN npm install less-plugin-clean-css
# Compile the CSS
# Note: this will not persist because /code/listenbrainz is a volume
# After bringing up a container, run this again inside the container
# to compile the less files
RUN lessc --clean-css listenbrainz/webserver/static/css/main.less > listenbrainz/webserver/static/css/main.css
# Consul Template service is already set up with the base image.
# Just need to copy the configuration.
COPY ./docker/consul-template.conf /etc/consul-template.conf
COPY ./docker/$deploy_env/uwsgi/uwsgi.service /etc/service/uwsgi/run
RUN chmod 755 /etc/service/uwsgi/run
COPY ./docker/$deploy_env/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini
COPY ./docker/prod/uwsgi/uwsgi-api-compat.ini /etc/uwsgi/uwsgi-api-compat.ini
# setup a log dir
RUN mkdir /logs
RUN chown -R daemon:daemon /logs