Skip to content

Commit 04db1ed

Browse files
lociiiauvipy
authored andcommitted
add docker env for local development
1 parent 35f9a0e commit 04db1ed

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM ubuntu:focal
2+
3+
ENV PYTHONUNBUFFERED 1
4+
ENV LC_ALL=C.UTF-8
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
7+
# the base image is also built using this Dockerfile, so we have to reset this
8+
USER root
9+
10+
RUN apt-get -y update && apt-get -y --no-install-recommends install \
11+
build-essential \
12+
gcc \
13+
gettext \
14+
python3-dev \
15+
python3-venv \
16+
&& \
17+
apt-get clean && \
18+
rm -rf /var/lib/apt/lists/* /usr/share/doc/* /usr/share/locale/* /usr/share/man/* && \
19+
mkdir -p /app && \
20+
(useradd -m app || true)
21+
22+
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
23+
COPY --from=docker/compose:1.23.2 /usr/local/bin/docker-compose /usr/bin/docker-compose
24+
25+
WORKDIR /app
26+
27+
ADD runtests/requirements.txt /app/
28+
29+
USER app
30+
31+
ENV PATH /home/app/venv/bin:${PATH}
32+
33+
RUN python3 -m venv ~/venv && \
34+
pip install -r /app/requirements.txt
35+
36+
ENV DJANGO_SETTINGS_MODULE settings
37+
38+
# *WARNING*: DO NOT "ADD . /app" because it would include the current settings in the base image, which is uploaded by
39+
# CI to docker hub; Since the settings currently include secrets, this would leak our credentials!
40+
41+
EXPOSE 8000
42+
43+
ENTRYPOINT ["/app/manage.py"]

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: "3.5"
2+
3+
services:
4+
django:
5+
build: .
6+
user: app
7+
command: "runserver 0:8000"
8+
volumes:
9+
- ./runtests:/app:cached
10+
- ./actstream:/app/actstream:cached
11+
- /var/run/docker.sock:/var/run/docker.sock
12+
environment:
13+
IPYTHONDIR: /app/.ipython
14+
HISTFILE: /app/.bash_history
15+
PYTHONDONTWRITEBYTECODE: "x"
16+
PYTHONWARNINGS: default
17+
restart: unless-stopped

docs/source/development.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Developing on django-activity-stream
2+
====================================
3+
4+
To simplify the development workflow, the project provides a docker container that can run the tests.
5+
6+
You will need `docker <https://www.docker.com/>`_ and `Docker Compose <https://docs.docker.com/compose/>`_.
7+
8+
.. code-block:: bash
9+
10+
docker-compose run --rm django test

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Contents:
3636
streams
3737
templatetags
3838
feeds
39+
development
3940
changelog
4041
api
4142

runtests/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Django>=2.2.17
2+
django-jsonfield
3+
django-jsonfield-compat
4+
tblib

0 commit comments

Comments
 (0)