Fix audio thumbnailing once and for all.
[mediagoblin.git] / Dockerfile-debian-python3-sqlite
CommitLineData
63a92e3b 1# A Dockerfile for MediaGoblin hacking.
86891869
BS
2#
3# Most development Docker images are built and run as root. That doesn't work
4# here because the `bower` command run within the `make` step, refuses to run as
5# root.
6#
7# To build this Docker image, run:
8#
9# docker build -t mediagoblin-python3 -f Dockerfile-python3 # or
10# docker build -t mediagoblin-python3 - < Dockerfile-python3 # with no build context
11#
12# The "- < Dockerfile" format advises Docker not to include the current
13# directory as build context.
14#
15# Before running the image you first need to first assign the "mediagoblin" and
16# "user_dev" directories to an artificial group (1024) on the host that is
17# mirrored within the image (details below):
18#
19# sudo chown --recursive :1024 mediagoblin user_dev
20# find mediagoblin user_dev -type d -exec chmod 775 {} \;
21# find mediagoblin user_dev -type f -exec chmod 664 {} \;
22#
23# Then you can run the image with the upstream MediaGoblin code:
24#
25# docker run --interactive --tty --publish 6543:6543 mediagoblin-python
26#
27# Or you can run with your local "mediagoblin" and "user_dev" directories
28# bind-mounted into the container. This provides automatic code reloading and
29# persistence:
30#
31# docker run --interactive --tty --publish 6543:6543 --volume ./mediagoblin:/opt/mediagoblin/mediagoblin --volume ./extlib:/opt/mediagoblin/extlib mediagoblin-python3
32#
33# Alternatively you use docker-compose instead of separate build/run steps:
34#
35# sudo chown --recursive :1024 mediagoblin user_dev
36# find mediagoblin user_dev -type d -exec chmod 775 {} \;
37# find mediagoblin user_dev -type f -exec chmod 664 {} \;
38# docker-compose up --build
63a92e3b
BS
39
40FROM debian:buster
41
42# Install bootstrap and configure dependencies. Currently requires virtualenv
43# rather than the more modern python3-venv (should be fixed).
44RUN apt-get update && apt-get install -y \
45automake \
46git \
47nodejs \
48npm \
49python3-dev \
50virtualenv
51
52# Install make and runtime dependencies.
86891869
BS
53#
54# Excluding python3-celery here due to conflict with dist-packges for a
55# compatible version of billiard.
63a92e3b
BS
56RUN apt-get install -y \
57python3-alembic \
63a92e3b
BS
58python3-jsonschema \
59python3-kombu \
60python3-lxml \
86891869 61python3-migrate \
63a92e3b
BS
62python3-py \
63python3-pytest \
64python3-pytest-xdist \
65python3-six \
86891869 66python3-snowballstemmer \
63a92e3b 67python3-sphinx \
86891869 68python3-sphinxcontrib.websupport \
63a92e3b
BS
69python3-webtest
70
71# Install audio dependencies.
72RUN apt-get install -y \
73gstreamer1.0-libav \
74gstreamer1.0-plugins-bad \
75gstreamer1.0-plugins-base \
76gstreamer1.0-plugins-good \
77gstreamer1.0-plugins-ugly \
78libsndfile1-dev \
79python3-gst-1.0 \
80python3-numpy \
81python3-scipy
82
83# Install video dependencies.
84RUN apt-get install -y \
85gir1.2-gst-plugins-base-1.0 \
86gir1.2-gstreamer-1.0 \
87gstreamer1.0-tools \
88python3-gi
89
90# Create working directory.
91RUN mkdir /opt/mediagoblin
92RUN chown -R www-data:www-data /opt/mediagoblin
93WORKDIR /opt/mediagoblin
94
95# Create /var/www because Bower writes some cache files into /var/www during
96# make, failing if it doesn't exist.
97RUN mkdir /var/www
98RUN chown root:www-data /var/www
99RUN chmod g+w /var/www
100
86891869
BS
101# Set up custom group to align with volume permissions for mounted
102# "mediagoblin/mediagoblin" and "mediagoblin/user_dev".
103#
104# The problem here is that the host's UID, GID and mode are used in the
105# container, but of course the container's user www-data is running under a
106# different UID/GID so can't read or write to the volume. It seems like there
107# should be a better approach, but we'll align volume permissions between host
108# and container as per
109# https://medium.com/@nielssj/docker-volumes-and-file-system-permissions-772c1aee23ca
110RUN groupadd --system mediagoblin --gid 1024 && adduser www-data mediagoblin
111
63a92e3b
BS
112USER www-data
113
86891869
BS
114# Copy upstream MediaGoblin into the image for use in the build process.
115#
116# This build process is somewhat complicated, because of Bower/NPM, translations
117# and Python dependencies, so it's not really feasible just to copy over a
118# requirements.txt like many Python Dockerfiles examples do. We need the full
119# source.
120#
121# While it is possible to copy the source from the current directory like this:
122#
123# COPY --chown=www-data:www-data . /opt/mediagoblin
124#
125# that approach to lots of confusing problems when your working directory has
126# changed from the default - say you've enabled some plugins or switched
127# database type. So instead we're doing a git clone. We could potentially use
128# `git archive` but this still wouldn't account for the submodules.
129RUN git clone --depth=1 git://git.savannah.gnu.org/mediagoblin.git -b master .
63a92e3b
BS
130RUN git submodule init && git submodule update
131
132RUN ./bootstrap.sh
133RUN VIRTUALENV_FLAGS='--system-site-packages' ./configure --with-python3
134RUN make
135
63a92e3b
BS
136# Only supported on Python 2.
137# RUN ./bin/pip install scikits.audiolab
138
86891869
BS
139# Only safe if being run on a clean git checkout. Otherwise you may have already
140# customised mediagoblin.ini to already install these.
63a92e3b
BS
141RUN echo '[[mediagoblin.media_types.audio]]' >> mediagoblin.ini
142RUN echo '[[mediagoblin.media_types.video]]' >> mediagoblin.ini
143
86891869
BS
144# Prepare the SQLite database.
145#
146# TODO: Should probably be done at runtime.
63a92e3b 147RUN ./bin/gmg dbupdate
63a92e3b
BS
148RUN ./bin/gmg adduser --username admin --password a --email admin@example.com
149RUN ./bin/gmg makeadmin admin
150
86891869
BS
151EXPOSE 6543/tcp
152
153# TODO: Is it possible to have a CMD here that is overriden by docker-compose?
154CMD ["./lazyserver.sh", "--server-name=broadcast"]