Skip to content

Commit 674b74e

Browse files
authored
Merge pull request #5 from onaio/add-7.4
2 parents c6ce579 + 6bd0998 commit 674b74e

10 files changed

Lines changed: 1044 additions & 185 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
env:
1313
python_version: "3.9.x"
14-
IMAGE: praekeltfoundation/rapidpro
15-
REGISTRY_USER: rapidproautomation
14+
IMAGE: rapidpro:ci
1615
REPO: rapidpro/rapidpro
16+
OIDC_VERSION: v1.1.1
1717
GREP_TIMEOUT: 360
1818
strategy:
1919
matrix:
20-
VERSION: [v7.2.4, v7.4.2]
20+
VERSION: [v8.0.1]
2121
steps:
2222
- uses: actions/checkout@v2
2323
- uses: actions/setup-python@v2
@@ -43,6 +43,7 @@ jobs:
4343
build-args: |
4444
RAPIDPRO_VERSION=${{matrix.VERSION}}
4545
RAPIDPRO_REPO=${{env.REPO}}
46+
OIDC_VERSION=${{env.OIDC_VERSION}}
4647
- name: Test Rapidpro Image
4748
run: |
4849
docker run --name rapidpro --env-file docker.envfile --link postgis --publish 8000:8000 --detach "${{ env.IMAGE }}"
@@ -59,34 +60,3 @@ jobs:
5960
if: always()
6061
run: |
6162
docker logs rapidpro
62-
- name: construct image metadata
63-
uses: docker/metadata-action@v3
64-
id: meta
65-
with:
66-
images: |
67-
praekeltfoundation/rapidpro
68-
ghcr.io/praekeltfoundation/rapidpro-docker
69-
tags: |
70-
type=pep440,pattern=v{{major}},value=${{matrix.VERSION}}
71-
type=pep440,pattern=v{{major}}.{{minor}},value=${{matrix.VERSION}}
72-
type=pep440,pattern=v{{version}},value=${{matrix.VERSION}}
73-
- name: login to ghcr
74-
uses: docker/login-action@v1
75-
with:
76-
registry: ghcr.io
77-
username: ${{github.actor}}
78-
password: ${{secrets.GITHUB_TOKEN}}
79-
- name: login to docker hub
80-
uses: docker/login-action@v1
81-
with:
82-
username: ${{secrets.DOCKER_USERNAME}}
83-
password: ${{secrets.DOCKER_PASSWORD}}
84-
- name: build and push
85-
uses: docker/build-push-action@v2
86-
with:
87-
push: ${{github.event_name != 'pull_request'}}
88-
tags: ${{steps.meta.outputs.tags}}
89-
context: .
90-
build-args: |
91-
RAPIDPRO_VERSION=${{matrix.VERSION}}
92-
RAPIDPRO_REPO=${{env.REPO}}

.travis.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

Dockerfile

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM ghcr.io/praekeltfoundation/python-base-nw:3.9-bullseye as builder
1+
FROM python:3.10.16-slim-bookworm as builder
22

33
ENV PIP_RETRIES=120 \
44
PIP_TIMEOUT=400 \
55
PIP_DEFAULT_TIMEOUT=400 \
66
C_FORCE_ROOT=1
77

8-
RUN apt-get-install.sh wget tar build-essential
8+
RUN apt update && apt install -y wget tar build-essential git
99

1010
WORKDIR /rapidpro
1111

@@ -18,25 +18,36 @@ RUN echo "Downloading RapidPro ${RAPIDPRO_VERSION} from https://github.com/$RAPI
1818
tar -xf rapidpro.tar.gz --strip-components=1 && \
1919
rm rapidpro.tar.gz
2020

21-
RUN pip install -U pip && pip install -U poetry
21+
RUN pip install -U pip && pip install -U poetry packaging
2222

2323
# Build Python virtualenv
2424
RUN python3 -m venv /venv
2525
ENV PATH="/venv/bin:$PATH"
2626
ENV VIRTUAL_ENV="/venv"
2727

2828
# Install configuration related dependencies
29-
RUN /venv/bin/pip install --upgrade pip && poetry install --no-interaction --no-dev && poetry add \
30-
"django-getenv==1.3.2" \
31-
"django-cache-url==3.2.3" \
32-
"uwsgi==2.0.20" \
33-
"whitenoise==5.3.0" \
34-
"flower==1.0.0"
29+
RUN /venv/bin/pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip && \
30+
/venv/bin/pip install --no-cache-dir \
31+
"django-getenv==1.3.2" \
32+
"django-cache-url==3.2.3" \
33+
"uwsgi==2.0.22" \
34+
"whitenoise==5.3.0" \
35+
"flower==1.2.0" \
36+
"sentry-sdk==2.5.1"
3537

36-
FROM ghcr.io/praekeltfoundation/python-base-nw:3.9-bullseye
38+
RUN poetry install --no-interaction --no-ansi --only main
39+
40+
# Install the Ona OIDC pip package.
41+
ARG OIDC_VERSION=v1.1.1
42+
ENV OIDC_VERSION=${OIDC_VERSION:-v1.1.1}
43+
RUN /venv/bin/pip install -e "git+https://github.com/onaio/ona-oidc.git@${OIDC_VERSION}#egg=ona-oidc"
44+
45+
FROM python:3.10.16-slim-bookworm
3746

3847
ARG RAPIDPRO_VERSION
48+
ARG RAPIDPRO_REPO
3949
ENV RAPIDPRO_VERSION=${RAPIDPRO_VERSION:-master}
50+
ENV RAPIDPRO_REPO=${RAPIDPRO_REPO:-rapidpro/rapidpro}
4051

4152
# Copy rapidpro and venv from builder
4253
COPY --from=builder /rapidpro /rapidpro
@@ -49,14 +60,17 @@ ENV VIRTUAL_ENV="/venv"
4960
# `pcre` is needed for uwsgi
5061
# `geos`, `gdal`, and `proj` are needed for `manage.py download_geojson` and `manage.py import_geojson`
5162
# `npm` for static file generation
52-
RUN apt-get-install.sh \
63+
RUN apt-get update -q && \
64+
apt-get install -y --no-install-recommends \
5365
postgresql-client \
5466
libmagic-dev \
5567
libpcre3 \
56-
libgeos-c1v5 \
57-
libgdal28 \
58-
libproj19 \
59-
npm
68+
libgeos-dev \
69+
libgdal-dev \
70+
libproj-dev \
71+
npm && \
72+
apt-get clean && \
73+
rm -rf /var/lib/apt/lists/*
6074

6175
WORKDIR /rapidpro
6276

@@ -76,6 +90,17 @@ COPY stack/clear-compressor-cache.py /rapidpro/
7690
EXPOSE 8000
7791
COPY stack/startup.sh /
7892

93+
# Drop privileges — run as a non-root user (uid 1000) with a real $HOME and
94+
# no login shell. uid 1000 is what Kubernetes' restricted Pod Security
95+
# Standard expects (runAsUser >= 1000) so the container's UID does not
96+
# overlap with privileged host system accounts.
97+
RUN groupadd -g 1000 rapidpro && \
98+
useradd -m -u 1000 -g rapidpro -s /sbin/nologin rapidpro && \
99+
chmod +x /startup.sh && \
100+
chown rapidpro:rapidpro /startup.sh && \
101+
chown -R rapidpro:rapidpro /rapidpro /venv
102+
USER rapidpro
103+
79104
LABEL org.label-schema.name="RapidPro" \
80105
org.label-schema.description="RapidPro allows organizations to visually build scalable interactive messaging applications." \
81106
org.label-schema.url="https://www.rapidpro.io/" \

README.md

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
RapidPro Docker
22
===============
33

4-
[![Build Status](https://travis-ci.org/praekeltfoundation/rapidpro-docker.svg?branch=master)](https://travis-ci.org/praekeltfoundation/rapidpro-docker)
5-
[![Docker Version](https://images.microbadger.com/badges/version/praekeltfoundation/rapidpro.svg)](https://hub.docker.com/r/praekeltfoundation/rapidpro/tags/ "Get the latest version from Docker Hub")
6-
7-
This repository's sole purpose is to build docker images versioned off of
8-
git tags published in rapidpro/rapidpro and upload them to Docker Hub.
9-
10-
The idea is:
11-
12-
1. Set up Travis Cron job to run every 24 hours
13-
3. The Travis build script should download the latest rapidpro/rapidpro
14-
tagged release matching `^v[0-9\.]$`
15-
4. Build the docker image and tag with the latest git tag.
16-
5. Push the docker image to Docker hub using credentials stored in
17-
Travis' secrets vault.
4+
This repository builds docker images of RapidPro versioned off git tags
5+
published in rapidpro/rapidpro and uploads them to Docker Hub via
6+
GitHub Actions (see `.github/workflows/ci.yaml`). The set of versions
7+
built is the `VERSION` matrix in that workflow.
188

199
Running RapidPro in Docker
2010
--------------------------
@@ -267,3 +257,57 @@ v6.0 to v6.2:
267257
v6.4 to v7.0:
268258
- Clear the sitestatic folder/S3 bucket and regenerate static files (otherwise icons don't work)
269259
- Ensure you're calling celery in the new CLI format, ie. `celery --app=temba beat`, not `celery beat --app=temba`
260+
261+
RapidPro 8.0.1 with OIDC
262+
------------------------
263+
264+
The `v8.0.1` build matrix entry produces an image with built-in OIDC support
265+
via the [`onaio/ona-oidc`](https://github.com/onaio/ona-oidc) Django app and
266+
Sentry telemetry via `sentry-sdk`. The image runs as the non-root `rapidpro`
267+
user (uid 1000) and uses `python:3.10.16-slim-bookworm` as its base.
268+
269+
Build:
270+
271+
$ docker build \
272+
--build-arg RAPIDPRO_VERSION=v8.0.1 \
273+
--build-arg RAPIDPRO_REPO=rapidpro/rapidpro \
274+
--build-arg OIDC_VERSION=v1.1.1 \
275+
-t onaio/rapidpro:v8.0.1-oidc .
276+
277+
Build args:
278+
279+
- `RAPIDPRO_VERSION` — git tag of `rapidpro/rapidpro` to build (default `master`).
280+
- `RAPIDPRO_REPO` — source repo (default `rapidpro/rapidpro`).
281+
- `OIDC_VERSION` — git tag of `onaio/ona-oidc` to install (default `v1.1.1`).
282+
283+
Additional environment variables specific to this build:
284+
285+
*ENABLE_OIDC*
286+
Set to ``on`` to enable OIDC login (loads the `oidc` app and adds
287+
`/oidc/<server>/login/` and `/oidc/<server>/logout/` routes). Defaults to ``off``.
288+
289+
*OPENID_CONNECT_VIEWSET_CONFIG*
290+
JSON-encoded config for the OIDC viewset (see `ona-oidc` README). Required when
291+
`ENABLE_OIDC=on`.
292+
293+
*OPENID_CONNECT_AUTH_SERVERS*
294+
JSON-encoded auth-server config for OIDC. Required when `ENABLE_OIDC=on`.
295+
296+
*OPENID_CONNECT_DEFAULT_AUTH_SERVER*
297+
Slug of the default auth server defined in `OPENID_CONNECT_AUTH_SERVERS`.
298+
Defaults to ``default``.
299+
300+
*SENTRY_DSN*
301+
DSN for Sentry error reporting. Optional; if unset, Sentry is not initialised.
302+
303+
*CSRF_TRUSTED_ORIGINS*
304+
Comma-separated list of origins to trust for CSRF (Django 4+). Example:
305+
``https://app.example.org/*,https://api.example.org/*``. Optional.
306+
307+
*NON_ISO6391_LANGUAGES*
308+
Comma-separated ISO 639-3 language codes to allow in addition to the built-in
309+
ISO 639-1 set (e.g. ``ach,nus,zne``). Optional.
310+
311+
*API_THROTTLE_V2_BROADCASTS*
312+
Throttle for v2 broadcast API (in addition to the existing
313+
``API_THROTTLE_V2_*`` family).

docker.envfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ MANAGEPY_COLLECTSTATIC=on
55
MANAGEPY_COMPRESS=on
66
MANAGEPY_INIT_DB=on
77
MANAGEPY_MIGRATE=on
8-
# Since we're not setting up OAuth tokens builds are subject
9-
# to IP based rate limiting on GitHub for TravisCI IPs which
10-
# can result in unpredictable builds.
8+
# GeoJSON import calls the GitHub API; without an auth token, builds
9+
# are subject to GitHub's per-IP rate limit and can fail unpredictably
10+
# when shared CI runners hit the limit.
1111
#
1212
# Set this to `on` if you really want to test this.
1313
MANAGEPY_IMPORT_GEOJSON=on
1414
# Use Uganda Relation ID can be used as a test
1515
OSM_RELATION_IDS=192796
16+
# enable oidc auth
17+
ENABLE_OIDC=on
18+
OIDC_VERSION=v1.1.1
19+
# OIDC viewset and auth-server configs; populate per deployment when
20+
# ENABLE_OIDC=on. Empty dicts are appropriate for the CI smoke test.
21+
OPENID_CONNECT_VIEWSET_CONFIG={}
22+
OPENID_CONNECT_AUTH_SERVERS={}

0 commit comments

Comments
 (0)