Skip to content

Commit ccf8dc8

Browse files
committed
Remove tests, docs and unused features from deps
1 parent 5536c64 commit ccf8dc8

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Dockerfile

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,32 @@ FROM python:3.12-alpine as base
55
FROM base as builder
66
# Allow statements and log messages to immediately appear in the Knative logs
77
ENV PYTHONUNBUFFERED=True
8+
ENV PYTHONDONTWRITEBYTECODE=true
89

910
COPY pyproject.toml README.md /
1011

1112
RUN --mount=type=cache,mode=0777,target=/root/.cache/pip \
1213
pip install --upgrade pip setuptools wheel && \
13-
pip install -e ".[dashboard]" && \
14-
mkdir -p /app/src
14+
pip install -e ".[dashboard]"
1515

16+
RUN find /usr/local/lib/python3.12/site-packages -name "test" -depth -type d -exec rm -rf '{}' \;
17+
RUN find /usr/local/lib/python3.12/site-packages -name "tests" -depth -type d -exec rm -rf '{}' \;
18+
RUN find /usr/local/lib/python3.12/site-packages -name "docs" -depth -type d -exec rm -rf '{}' \;
19+
RUN find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
20+
21+
RUN rm -rf /usr/local/lib/python3.12/site-packages/panel/dist/bundled/deckglplot
22+
RUN rm -rf /usr/local/lib/python3.12/site-packages/panel/dist/bundled/abstractvtkplot
23+
RUN rm -rf /usr/local/lib/python3.12/site-packages/panel/dist/bundled/aceplot
24+
RUN rm -rf /usr/local/lib/python3.12/site-packages/panel/dist/bundled/bootstrap5
25+
RUN rm -rf /usr/local/lib/python3.12/site-packages/panel/dist/bundled/plotlyplot
26+
RUN rm -rf /usr/local/lib/python3.12/site-packages/panel/dist/bundled/bootstrap4
27+
28+
# stats depends on spatial, special, sparse, linalg, ndimage, fft
29+
RUN rm -rf /usr/local/lib/python3.12/site-packages/scipy/signal
30+
RUN rm -rf /usr/local/lib/python3.12/site-packages/scipy/misc
31+
RUN rm -rf /usr/local/lib/python3.12/site-packages/scipy/cluster
32+
33+
RUN mkdir -p /app/src
1634
COPY src /app/src
1735
COPY tests/data /app/tests/data
1836
COPY panel /app/panel
@@ -22,6 +40,7 @@ COPY docs/_static /app/_static
2240
FROM base as panel
2341
# Allow statements and log messages to immediately appear in the Knative logs
2442
ENV PYTHONUNBUFFERED=True
43+
ENV PYTHONDONTWRITEBYTECODE=true
2544
ENV PYTHONPATH=/app/src
2645
ENV PYTHONIOENCODING=utf-8
2746
ENV MPLCONFIGDIR=/tmp/matplotlib
@@ -31,6 +50,12 @@ COPY --from=builder /usr/local/lib/python3.12/site-packages/ /usr/local/lib/pyth
3150
COPY --from=builder /usr/local/bin/panel /usr/local/bin/panel
3251
COPY --from=builder /app /app
3352

53+
# Basic security hardening
54+
RUN rm -rf /usr/local/lib/python3.12/site-packages/pip
55+
RUN rm -rf /usr/local/lib/python3.12/site-packages/wheel
56+
RUN rm -rf /usr/local/lib/python3.12/site-packages/setuptools
57+
RUN apk --purge del apk-tools
58+
3459
RUN addgroup -S app && adduser -S app -G app
3560

3661
USER app

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ serve-oauth: ## Serve Panel dashboard - Prod mode with OAuth2. Needs: PANEL_OAU
6363
--reuse-sessions --warm
6464

6565
# Deployment commands
66+
# --progress=plain
6667

6768
build-local:
6869
docker build -f ./Dockerfile \
@@ -80,6 +81,7 @@ run-local: build-local
8081
-e PANEL_OAUTH_REDIRECT_URI=$(PANEL_OAUTH_REDIRECT_URI) \
8182
-e PANEL_OAUTH_SECRET=$(PANEL_OAUTH_SECRET) \
8283
-e PANEL_OAUTH_KEY=$(PANEL_OAUTH_KEY) \
84+
-e PANEL_OAUTH_ENCRYPTION=$(PANEL_OAUTH_ENCRYPTION) \
8385
-p "5006:8080" \
8486
simdec-panel-local:$(version)
8587

@@ -101,6 +103,7 @@ run: build
101103
-e PANEL_OAUTH_REDIRECT_URI=$(PANEL_OAUTH_REDIRECT_URI) \
102104
-e PANEL_OAUTH_SECRET=$(PANEL_OAUTH_SECRET) \
103105
-e PANEL_OAUTH_KEY=$(PANEL_OAUTH_KEY) \
106+
-e PANEL_OAUTH_ENCRYPTION=$(PANEL_OAUTH_ENCRYPTION) \
104107
-p "5006:8080" \
105108
simdec-panel:$(version)
106109

0 commit comments

Comments
 (0)