Skip to content

Commit 5d76f57

Browse files
committed
chore(controller): set venv profile
1 parent 94c817e commit 5d76f57

File tree

8 files changed

+44
-36
lines changed

8 files changed

+44
-36
lines changed

charts/controller/templates/controller-cronjob-daily.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
- /bin/bash
3838
- -c
3939
args:
40-
- python /app/manage.py load_db_state_to_k8s
40+
- python /workspace/manage.py load_db_state_to_k8s
4141
{{- include "controller.envs" . | indent 12 }}
4242
- image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/controller:{{.Values.imageTag}}
4343
imagePullPolicy: {{.Values.pull_policy}}
@@ -46,7 +46,7 @@ spec:
4646
- /bin/bash
4747
- -c
4848
args:
49-
- python -u /app/manage.py measure_apps
49+
- python -u /workspace/manage.py measure_apps
5050
{{- include "controller.envs" . | indent 12 }}
5151
- image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/controller:{{.Values.imageTag}}
5252
imagePullPolicy: {{.Values.pull_policy}}
@@ -55,7 +55,7 @@ spec:
5555
- /bin/bash
5656
- -c
5757
args:
58-
- python -u /app/manage.py measure_resources
58+
- python -u /workspace/manage.py measure_resources
5959
{{- include "controller.envs" . | indent 12 }}
6060
- image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/controller:{{.Values.imageTag}}
6161
imagePullPolicy: {{.Values.pull_policy}}
@@ -64,6 +64,6 @@ spec:
6464
- /bin/bash
6565
- -c
6666
args:
67-
- python -u /app/manage.py measure_volumes
67+
- python -u /workspace/manage.py measure_volumes
6868
{{- include "controller.envs" . | indent 12 }}
6969

charts/controller/templates/controller-cronjob-hourly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ spec:
3737
- /bin/bash
3838
- -c
3939
args:
40-
- python -u /app/manage.py measure_networks
40+
- python -u /workspace/manage.py measure_networks
4141
{{- include "controller.envs" . | indent 12 }}

rootfs/Dockerfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@ FROM docker.io/drycc/base:bullseye
33
RUN adduser --system \
44
--shell /bin/bash \
55
--disabled-password \
6-
--home /app \
6+
--home /workspace \
77
--group \
88
drycc
99

1010
ENV PYTHON_VERSION="3.10.2"
11-
COPY requirements.txt /app/requirements.txt
11+
COPY requirements.txt /workspace/requirements.txt
1212

1313
RUN buildDeps='gcc libffi-dev libpq-dev rustc cargo'; \
1414
install-packages $buildDeps \
1515
&& install-stack python $PYTHON_VERSION && . init-stack \
16-
&& python3 -m venv /app/.venv \
17-
&& source /app/.venv/bin/activate \
18-
&& pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt \
16+
&& python3 -m venv /workspace/.venv \
17+
&& source /workspace/.venv/bin/activate \
18+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /workspace/requirements.txt \
19+
&& chown -R drycc:drycc /workspace \
20+
# set env
21+
&& echo "source /workspace/.venv/bin/activate" >> /opt/drycc/python/profile.d/python.sh \
1922
# cleanup
20-
&& scanelp /app/.venv/lib > runtime.txt \
23+
&& scanelp /workspace/.venv/lib > runtime.txt \
2124
&& apt-get purge -y --auto-remove $buildDeps \
2225
&& install-packages $(< runtime.txt) \
2326
&& apt-get autoremove -y \
@@ -37,9 +40,9 @@ RUN buildDeps='gcc libffi-dev libpq-dev rustc cargo'; \
3740
/usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \
3841
&& mkdir -p /usr/share/man/man{1..8}
3942

40-
COPY . /app
43+
COPY . /workspace
4144

4245
USER drycc
43-
WORKDIR /app
44-
CMD ["PATH=/app/.venv/bin:\$PATH", "/app/bin/boot"]
46+
WORKDIR /workspace
47+
CMD ["/workspace/bin/boot"]
4548
EXPOSE 8000

rootfs/Dockerfile.test

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
FROM docker.io/drycc/base:bullseye
22

3-
COPY requirements.txt /app/requirements.txt
4-
COPY dev_requirements.txt /app/dev_requirements.txt
3+
RUN adduser --system \
4+
--shell /bin/bash \
5+
--disabled-password \
6+
--home /workspace \
7+
--group \
8+
drycc
9+
10+
COPY requirements.txt /workspace/requirements.txt
11+
COPY dev_requirements.txt /workspace/dev_requirements.txt
512

613
ENV PGDATA="/opt/drycc/postgresql/data" \
714
PYTHON_VERSION="3.10.2" \
@@ -17,12 +24,15 @@ RUN buildDeps='gcc rustc cargo libffi-dev musl-dev openssl'; \
1724
&& install-stack rabbitmq $RABBITMQ_VERSION \
1825
&& install-stack postgresql $POSTGRES_VERSION \
1926
&& install-stack gosu $GOSU_VERSION && . init-stack \
20-
&& python3 -m venv /app/.venv \
21-
&& source /app/.venv/bin/activate \
22-
&& pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt \
23-
&& pip3 install --disable-pip-version-check --no-cache-dir -r /app/dev_requirements.txt \
27+
&& python3 -m venv /workspace/.venv \
28+
&& source /workspace/.venv/bin/activate \
29+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /workspace/requirements.txt \
30+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /workspace/dev_requirements.txt \
31+
&& chown -R drycc:drycc /workspace \
32+
# set env
33+
&& echo "source /workspace/.venv/bin/activate" >> /opt/drycc/python/profile.d/python.sh \
2434
# cleanup
25-
&& scanelp /app/.venv/lib > runtime.txt \
35+
&& scanelp /workspace/.venv/lib > runtime.txt \
2636
&& apt-get purge -y --auto-remove $buildDeps \
2737
&& install-packages $(< runtime.txt) \
2838
&& apt-get autoremove -y \
@@ -46,7 +56,7 @@ RUN buildDeps='gcc rustc cargo libffi-dev musl-dev openssl'; \
4656
&& chown -R postgres:postgres /run/postgresql $PGDATA \
4757
&& gosu postgres initdb -D $PGDATA
4858

49-
COPY . /app
50-
WORKDIR /app
51-
CMD ["/app/bin/boot"]
59+
COPY . /workspace
60+
WORKDIR /workspace
61+
CMD ["/workspace/bin/boot"]
5262
EXPOSE 8000

rootfs/bin/boot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ echo system information:
1313
echo "Django Version: $(python manage.py --version)"
1414
python --version
1515

16-
mkdir -p /app/data/logs
17-
chmod -R 777 /app/data/logs
16+
mkdir -p /workspace/data/logs
17+
chmod -R 777 /workspace/data/logs
1818

1919
echo "Django checks:"
20-
python /app/manage.py check --deploy api
20+
python /workspace/manage.py check --deploy api
2121

2222
echo ""
2323
echo "Health Checks:"
24-
python /app/manage.py healthchecks
24+
python /workspace/manage.py healthchecks
2525

2626
echo ""
2727
echo "Database Migrations:"
28-
python /app/manage.py migrate --noinput
28+
python /workspace/manage.py migrate --noinput
2929

3030
# spawn a gunicorn server in the background
3131
echo ""
3232
echo "Starting up Gunicorn"
33-
gunicorn -c /app/drycc/gunicorn/config.py api.wsgi &
33+
gunicorn -c /workspace/drycc/gunicorn/config.py api.wsgi &
3434

3535
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
3636
function on_exit() {

rootfs/bin/test-style

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55

66
# fail hard and fast even on pipelines
77
set -eou pipefail
8-
# shellcheck disable=SC1091
9-
source /app/.venv/bin/activate
8+
109
flake8 --show-source

rootfs/bin/test-unit

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
# fail hard and fast even on pipelines
77
set -eou pipefail
8-
# shellcheck disable=SC1091
9-
source /app/.venv/bin/activate
108

119
function start_redis() {
1210
cd /tmp

rootfs/bin/upload-coverage

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55

66
# fail hard and fast even on pipelines
77
set -eou pipefail
8-
# shellcheck disable=SC1091
9-
source /app/.venv/bin/activate
108

119
codecov --required

0 commit comments

Comments
 (0)