Skip to content

Commit 9ded3a8

Browse files
committed
chore(passport): set venv profile
1 parent 6b991f5 commit 9ded3a8

6 files changed

Lines changed: 44 additions & 38 deletions

File tree

rootfs/Dockerfile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM docker.io/drycc/base:bullseye as build-app
22

3-
ADD web /app
4-
WORKDIR /app
3+
ADD web /workspace
4+
WORKDIR /workspace
55

66
ENV NODE_VERSION="16.14.0"
77

@@ -15,21 +15,24 @@ FROM docker.io/drycc/base:bullseye
1515
RUN adduser --system \
1616
--shell /bin/bash \
1717
--disabled-password \
18-
--home /app \
18+
--home /workspace \
1919
--group \
2020
drycc
2121

2222
ENV PYTHON_VERSION="3.10.2"
23-
COPY requirements.txt /app/requirements.txt
23+
COPY requirements.txt /workspace/requirements.txt
2424

2525
RUN buildDeps='gcc rustc cargo libffi-dev musl-dev libldap2-dev libsasl2-dev'; \
2626
install-packages $buildDeps \
2727
&& install-stack python $PYTHON_VERSION && . init-stack \
28-
&& python3 -m venv /app/.venv \
29-
&& source /app/.venv/bin/activate \
30-
&& pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt \
28+
&& python3 -m venv /workspace/.venv \
29+
&& source /workspace/.venv/bin/activate \
30+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /workspace/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 \
3134
# cleanup
32-
&& scanelp /app/.venv/lib > runtime.txt \
35+
&& scanelp /workspace/.venv/lib > runtime.txt \
3336
&& apt-get purge -y --auto-remove $buildDeps \
3437
&& install-packages $(< runtime.txt) \
3538
&& apt-get autoremove -y \
@@ -49,10 +52,10 @@ RUN buildDeps='gcc rustc cargo libffi-dev musl-dev libldap2-dev libsasl2-dev'; \
4952
/usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \
5053
&& mkdir -p /usr/share/man/man{1..8}
5154

52-
COPY . /app
53-
COPY --from=build-app /app/dist /app/web/dist
55+
COPY . /workspace
56+
COPY --from=build-app /workspace/dist /workspace/web/dist
5457

5558
USER drycc
56-
WORKDIR /app
57-
CMD ["PATH=/app/.venv/bin:\$PATH", "/app/bin/boot"]
59+
WORKDIR /workspace
60+
CMD ["/workspace/bin/boot"]
5861
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="/var/lib/postgresql/data" \
714
PYTHON_VERSION="3.10.2" \
@@ -13,12 +20,15 @@ RUN buildDeps='gcc rustc cargo libffi-dev musl-dev libldap2-dev libsasl2-dev'; \
1320
&& install-stack python $PYTHON_VERSION \
1421
&& install-stack postgresql $POSTGRES_VERSION \
1522
&& install-stack gosu $GOSU_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 \
19-
&& pip3 install --disable-pip-version-check --no-cache-dir -r /app/dev_requirements.txt \
23+
&& python3 -m venv /workspace/.venv \
24+
&& source /workspace/.venv/bin/activate \
25+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /workspace/requirements.txt \
26+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /workspace/dev_requirements.txt \
27+
&& chown -R drycc:drycc /workspace \
28+
# set env
29+
&& echo "source /workspace/.venv/bin/activate" >> /opt/drycc/python/profile.d/python.sh \
2030
# cleanup
21-
&& scanelp /app/.venv/lib > runtime.txt \
31+
&& scanelp /workspace/.venv/lib > runtime.txt \
2232
&& apt-get purge -y --auto-remove $buildDeps \
2333
&& install-packages $(< runtime.txt) \
2434
&& apt-get autoremove -y \
@@ -42,7 +52,7 @@ RUN buildDeps='gcc rustc cargo libffi-dev musl-dev libldap2-dev libsasl2-dev'; \
4252
&& chown -R postgres:postgres /run/postgresql $PGDATA \
4353
&& gosu postgres initdb -D $PGDATA
4454

45-
COPY . /app
46-
WORKDIR /app
47-
CMD ["/app/bin/boot"]
55+
COPY . /workspace
56+
WORKDIR /workspace
57+
CMD ["/workspace/bin/boot"]
4858
EXPOSE 8000

rootfs/bin/boot

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@
55

66
# fail hard and fast even on pipelines
77
set -eo pipefail
8-
# shellcheck disable=SC1091
9-
source /app/.venv/bin/activate
108
# set debug based on envvar
119
[[ $DRYCC_DEBUG == "true" ]] && set -x
1210

1311
echo system information:
1412
echo "Django Version: $(./manage.py --version)"
1513
python --version
1614

17-
mkdir -p /app/data/logs
18-
chmod -R 777 /app/data/logs
15+
mkdir -p /workspace/data/logs
16+
chmod -R 777 /workspace/data/logs
1917

2018
echo "Django checks:"
21-
python /app/manage.py check --deploy api
19+
python /workspace/manage.py check --deploy api
2220

2321
echo ""
2422
echo "Health Checks:"
25-
python /app/manage.py healthchecks
23+
python /workspace/manage.py healthchecks
2624

2725
echo ""
2826
echo "Database Migrations:"
29-
python /app/manage.py migrate --noinput
27+
python /workspace/manage.py migrate --noinput
3028

3129
echo ""
3230
echo "Collect static files in a single location:"
@@ -35,17 +33,17 @@ python manage.py collectstatic --noinput
3533
echo ""
3634
if [ "${ADMIN_USERNAME}" ] && [ "${ADMIN_PASSWORD}" ] && [ "${ADMIN_EMAIL}" ]; then
3735
echo "Create administrator"
38-
python /app/manage.py createadminuser --username "${ADMIN_USERNAME}" --password "${ADMIN_PASSWORD}" --noinput --email "${ADMIN_EMAIL}"
36+
python /workspace/manage.py createadminuser --username "${ADMIN_USERNAME}" --password "${ADMIN_PASSWORD}" --noinput --email "${ADMIN_EMAIL}"
3937
fi
4038

4139
echo ""
4240
echo "Create application for drycc controller "
43-
python /app/manage.py create_oauth2_application
41+
python /workspace/manage.py create_oauth2_application
4442

4543
# spawn a gunicorn server in the background
4644
echo ""
4745
echo "Starting up Gunicorn"
48-
gunicorn -c /app/passport/gunicorn/config.py api.wsgi &
46+
gunicorn -c /workspace/passport/gunicorn/config.py api.wsgi &
4947

5048
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
5149
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 creating_rsa_key() {
1210
mkdir -p /var/run/secrets/drycc/passport/ \

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)