Skip to content

Commit fe9e407

Browse files
committed
Pin and harden real PQC Docker image
1 parent bc4eb58 commit fe9e407

1 file changed

Lines changed: 28 additions & 40 deletions

File tree

Dockerfile.pqc

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
1-
FROM python:3.12-slim
1+
FROM python:3.12.8-slim-bookworm
22

3+
ARG LIBOQS_REF=0.12.0
4+
ARG LIBOQS_PYTHON_REF=0.12.0
5+
6+
LABEL maintainer="Dr. Chokri NOUAR"
37
LABEL project="Hybrid-PKI-Lab"
4-
LABEL description="Hybrid PKI Lab with liboqs and liboqs-python"
5-
LABEL maintainer="Chokri"
8+
LABEL description="Pinned real-PQC environment for the educational lab"
69

7-
ENV PYTHONDONTWRITEBYTECODE=1
8-
ENV PYTHONUNBUFFERED=1
9-
ENV PIP_NO_CACHE_DIR=1
10-
ENV APP_HOME=/app
11-
ENV OQS_INSTALL_PATH=/usr/local
12-
ENV LD_LIBRARY_PATH=/usr/local/lib
10+
ENV PYTHONDONTWRITEBYTECODE=1 \
11+
PYTHONUNBUFFERED=1 \
12+
PIP_NO_CACHE_DIR=1 \
13+
APP_HOME=/app \
14+
OQS_INSTALL_PATH=/usr/local \
15+
LD_LIBRARY_PATH=/usr/local/lib \
16+
HYBRID_PKI_DISABLE_OQS=0
1317

1418
WORKDIR ${APP_HOME}
1519

1620
RUN apt-get update && apt-get install -y --no-install-recommends \
17-
git \
18-
cmake \
19-
ninja-build \
20-
build-essential \
21-
pkg-config \
22-
libssl-dev \
23-
ca-certificates \
24-
curl \
25-
python3-dev \
21+
git cmake ninja-build build-essential pkg-config libssl-dev ca-certificates python3-dev \
2622
&& rm -rf /var/lib/apt/lists/*
2723

28-
RUN git clone --depth 1 https://github.com/open-quantum-safe/liboqs.git /tmp/liboqs \
29-
&& cmake -S /tmp/liboqs -B /tmp/liboqs/build \
30-
-GNinja \
24+
RUN git clone --depth 1 --branch "${LIBOQS_REF}" \
25+
https://github.com/open-quantum-safe/liboqs.git /tmp/liboqs \
26+
&& cmake -S /tmp/liboqs -B /tmp/liboqs/build -GNinja \
3127
-DCMAKE_INSTALL_PREFIX=/usr/local \
3228
-DBUILD_SHARED_LIBS=ON \
3329
-DOQS_BUILD_ONLY_LIB=ON \
3430
-DOQS_USE_OPENSSL=ON \
35-
&& cmake --build /tmp/liboqs/build \
31+
&& cmake --build /tmp/liboqs/build --parallel 2 \
3632
&& cmake --install /tmp/liboqs/build \
3733
&& ldconfig \
3834
&& rm -rf /tmp/liboqs
3935

40-
COPY requirements.txt .
41-
COPY pyproject.toml .
42-
COPY README.md .
43-
36+
COPY requirements.txt pyproject.toml README.md ./
4437
RUN python -m pip install --upgrade pip setuptools wheel \
4538
&& pip install -r requirements.txt \
46-
&& pip install liboqs-python
39+
&& pip install "git+https://github.com/open-quantum-safe/liboqs-python.git@${LIBOQS_PYTHON_REF}" \
40+
&& pip install .
4741

4842
COPY src ./src
4943
COPY tests ./tests
@@ -52,19 +46,13 @@ COPY examples ./examples
5246
COPY docs ./docs
5347
COPY scripts ./scripts
5448

55-
RUN pip install -e .
49+
RUN groupadd --system hybridpki \
50+
&& useradd --system --gid hybridpki --home-dir /app hybridpki \
51+
&& mkdir -p certs/root certs/intermediate certs/issued certs/revoked certs/hybrid benchmarks/results logs \
52+
&& chown -R hybridpki:hybridpki /app \
53+
&& python -c "import oqs; print('Pinned liboqs-python loaded successfully')"
5654

57-
RUN mkdir -p \
58-
certs/root \
59-
certs/intermediate \
60-
certs/issued \
61-
certs/revoked \
62-
certs/hybrid \
63-
benchmarks/results \
64-
logs
65-
66-
RUN python -c "import oqs; print('liboqs-python loaded successfully')"
55+
USER hybridpki
6756

6857
EXPOSE 8000
69-
70-
CMD ["python", "-m", "uvicorn", "hybrid_pki.api.main:app", "--host", "0.0.0.0", "--port", "8000"]
58+
CMD ["python", "-m", "uvicorn", "hybrid_pki.api.main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)