Skip to content

Commit 240fe78

Browse files
agjohnsonhumitos
authored andcommitted
Add a contrib Dockerfile for local build image on Linux
This is necessary as permissions are all incorrect on the paths that are shared between the host system and the Docker build container. Closes #2692
1 parent edf2e60 commit 240fe78

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

contrib/Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM readthedocs/build:4.0rc1
2+
3+
ARG username
4+
ARG uid=1000
5+
ARG gid=$uid
6+
ARG label=latest
7+
8+
ENV USERNAME ${username}
9+
ENV UID ${uid}
10+
ENV GID ${gid}
11+
12+
USER root
13+
RUN groupadd --gid $GID $USERNAME
14+
RUN useradd -m --uid $UID --gid $GID $USERNAME
15+
USER $username
16+
17+
CMD ["/bin/bash"]

contrib/docker_build.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
username=`id -nu`
4+
uid=`id -u`
5+
gid=`id -g`
6+
7+
version=$1
8+
[ -n "${version}" ] || version="latest"
9+
10+
docker build \
11+
-t readthedocs/build:dev \
12+
--build-arg username=${username} \
13+
--build-arg uid=${uid} \
14+
--build-arg gid=${gid} \
15+
--build-arg label=${version} \
16+
.

contrib/readme.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
Contrib
2+
=======
3+
4+
Building development Docker image
5+
---------------------------------
6+
7+
If you run Linux, you likely need to build a local Docker image that extends our
8+
default image::
9+
10+
cd contrib/
11+
./docker_build.sh
12+
113
Running Read the Docs via Supervisord
2-
=====================================
14+
-------------------------------------
315

416
This is the easiest way to start all of the commands you'll need for development
517
in an environment relatively close to the production evironment. All you need is

docs/development/buildenvironments.rst

+20
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,23 @@ DOCKER_VERSION
8282
Version of the API to use for the Docker API client.
8383

8484
Default: :djangosetting:`DOCKER_VERSION`
85+
86+
Local development
87+
-----------------
88+
89+
On Linux development environments, it's likely that your UID and GID do not
90+
match the ``docs`` user that is set up as the default user for builds. In this
91+
case, it's necessary to make a new image that overrides this user::
92+
93+
cd contrib/
94+
./docker_build.sh
95+
96+
You can also specify a specific image version to use::
97+
98+
cd contrib/
99+
./docker_build.sh 4.0rc1
100+
101+
This will create a new image, ``readthedocs/build:dev``, which you can specify
102+
as the default image in local settings overrides::
103+
104+
DOCKER_IMAGE = 'readthedocs/build:dev'

0 commit comments

Comments
 (0)