Skip to content

Commit c1b4819

Browse files
Update dev containerfile + add dev docker-compose file for local setup (#102)
1 parent abf5982 commit c1b4819

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

Containerfile.dev

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
FROM rockylinux:8
1+
FROM rockylinux:9
22

33
ENV PYTHONDONTWRITEBYTECODE 1
44
ENV PYTHONUNBUFFERED 1
55

6-
RUN yum install -y python36 python3-devel python3-ldap python3-pip openldap-devel gcc mariadb-devel xmlsec1 xmlsec1-openssl patch && \
6+
RUN yum install -y --enablerepo=crb \
7+
python3.12 python3.12-devel python3.12-pip python3-ldap openldap-devel gcc mariadb-devel xmlsec1 xmlsec1-openssl patch git && \
78
yum clean all && \
89
rm -rf /var/cache/yum
910

1011
WORKDIR /opt/userportal
1112

1213
COPY requirements.txt ./
1314

14-
RUN pip3 install --upgrade pip && \
15-
pip3 install --no-cache-dir -r requirements.txt
15+
RUN pip3.12 install --upgrade pip && \
16+
pip3.12 install --no-cache-dir -r requirements.txt && \
17+
pip3.12 install --no-cache-dir whitenoise==6.11.0
1618

1719
COPY . .
1820

19-
RUN patch /usr/local/lib/python3.6/site-packages/ldapdb/backends/ldap/base.py < /opt/userportal/ldapdb.patch
21+
RUN patch /usr/local/lib/python3.12/site-packages/ldapdb/backends/ldap/base.py < /opt/userportal/ldapdb.patch
22+
23+
RUN sed -i "/'django.middleware.security.SecurityMiddleware',/a \ \ \ \ 'whitenoise.middleware.WhiteNoiseMiddleware'," userportal/settings/10-base.py
24+
25+
RUN cat <<'EOF' > cloud.yml
26+
projects:
27+
someproject:
28+
members:
29+
- someuser
30+
EOF
31+
32+
RUN python3.12 manage.py collectstatic --noinput
2033

2134
EXPOSE 8000
22-
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
35+
CMD ["sh", "-c", "python3.12 manage.py migrate && python3.12 manage.py runserver 0.0.0.0:8000"]

docker-compose.dev.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
db:
3+
image: mysql:9.4
4+
restart: always
5+
environment:
6+
MYSQL_ROOT_PASSWORD: rootpassword
7+
MYSQL_DATABASE: mydatabase
8+
MYSQL_USER: user
9+
MYSQL_PASSWORD: userpassword
10+
ports:
11+
- "3306:3306"
12+
healthcheck:
13+
test: ["CMD-SHELL", "mysql -h localhost -u $$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE -e 'SELECT 1'"]
14+
interval: 5s
15+
timeout: 5s
16+
retries: 3
17+
start_period: 30s
18+
app:
19+
build:
20+
context: .
21+
dockerfile: Containerfile.dev
22+
restart: always
23+
environment:
24+
REMOTE_USER: someuser@alliancecan.ca
25+
affiliation: staff@alliancecan.ca
26+
ports:
27+
- "8000:8000"
28+
depends_on:
29+
db:
30+
condition: service_healthy

docs/development.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ Then you can launch the example server with:
1818
REMOTE_USER=someuser@alliancecan.ca affiliation=staff@alliancecan.ca python manage.py runserver
1919
```
2020

21+
Or using Docker Compose with:
22+
```
23+
docker-compose -f docker-compose.dev.yml up --build
24+
```
25+
2126
This will run the portal with the user `someuser` logged in as a staff member.
2227

2328
Automated Django tests are also available, they can be run with:

0 commit comments

Comments
 (0)