Commit | Line | Data |
---|---|---|
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 | |
40 | FROM debian:buster | |
41 | ||
42 | # Install bootstrap and configure dependencies. Currently requires virtualenv | |
43 | # rather than the more modern python3-venv (should be fixed). | |
44 | RUN apt-get update && apt-get install -y \ | |
45 | automake \ | |
46 | git \ | |
47 | nodejs \ | |
48 | npm \ | |
49 | python3-dev \ | |
50 | virtualenv | |
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 |
56 | RUN apt-get install -y \ |
57 | python3-alembic \ | |
63a92e3b BS |
58 | python3-jsonschema \ |
59 | python3-kombu \ | |
60 | python3-lxml \ | |
86891869 | 61 | python3-migrate \ |
63a92e3b BS |
62 | python3-py \ |
63 | python3-pytest \ | |
64 | python3-pytest-xdist \ | |
65 | python3-six \ | |
86891869 | 66 | python3-snowballstemmer \ |
63a92e3b | 67 | python3-sphinx \ |
86891869 | 68 | python3-sphinxcontrib.websupport \ |
63a92e3b BS |
69 | python3-webtest |
70 | ||
71 | # Install audio dependencies. | |
72 | RUN apt-get install -y \ | |
73 | gstreamer1.0-libav \ | |
74 | gstreamer1.0-plugins-bad \ | |
75 | gstreamer1.0-plugins-base \ | |
76 | gstreamer1.0-plugins-good \ | |
77 | gstreamer1.0-plugins-ugly \ | |
78 | libsndfile1-dev \ | |
79 | python3-gst-1.0 \ | |
80 | python3-numpy \ | |
81 | python3-scipy | |
82 | ||
83 | # Install video dependencies. | |
84 | RUN apt-get install -y \ | |
85 | gir1.2-gst-plugins-base-1.0 \ | |
86 | gir1.2-gstreamer-1.0 \ | |
87 | gstreamer1.0-tools \ | |
88 | python3-gi | |
89 | ||
90 | # Create working directory. | |
91 | RUN mkdir /opt/mediagoblin | |
92 | RUN chown -R www-data:www-data /opt/mediagoblin | |
93 | WORKDIR /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. | |
97 | RUN mkdir /var/www | |
98 | RUN chown root:www-data /var/www | |
99 | RUN 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 | |
110 | RUN groupadd --system mediagoblin --gid 1024 && adduser www-data mediagoblin | |
111 | ||
63a92e3b BS |
112 | USER 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. | |
129 | RUN git clone --depth=1 git://git.savannah.gnu.org/mediagoblin.git -b master . | |
63a92e3b BS |
130 | RUN git submodule init && git submodule update |
131 | ||
132 | RUN ./bootstrap.sh | |
133 | RUN VIRTUALENV_FLAGS='--system-site-packages' ./configure --with-python3 | |
134 | RUN 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 |
141 | RUN echo '[[mediagoblin.media_types.audio]]' >> mediagoblin.ini |
142 | RUN 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 | 147 | RUN ./bin/gmg dbupdate |
63a92e3b BS |
148 | RUN ./bin/gmg adduser --username admin --password a --email admin@example.com |
149 | RUN ./bin/gmg makeadmin admin | |
150 | ||
86891869 BS |
151 | EXPOSE 6543/tcp |
152 | ||
153 | # TODO: Is it possible to have a CMD here that is overriden by docker-compose? | |
154 | CMD ["./lazyserver.sh", "--server-name=broadcast"] |