From 19c6e2a29b6ae32c8ae90970f3fedce81b1a1274 Mon Sep 17 00:00:00 2001 From: Anirudh Hegde Date: Mon, 15 Apr 2024 20:09:29 +0530 Subject: [PATCH 1/3] updated Dockerfile --- docker-example/Dockerfile | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/docker-example/Dockerfile b/docker-example/Dockerfile index 2c36c822..7dc1e5ee 100644 --- a/docker-example/Dockerfile +++ b/docker-example/Dockerfile @@ -11,21 +11,22 @@ COPY . . # Create virtualenv which will be copied into final container ENV VIRTUAL_ENV=/app/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" -RUN python3.11 -m venv $VIRTUAL_ENV - -# Install app requirements and nextpy inside virtualenv -RUN pip install -r requirements.txt - -# Deploy templates and prepare app -RUN nextpy init - -# Export static copy of frontend to /app/.web/_static -RUN nextpy export --frontend-only --no-zip - -# Copy static files out of /app to save space in backend image -RUN mv .web/_static /tmp/_static -RUN rm -rf .web && mkdir .web -RUN mv /tmp/_static .web/_static +RUN \ + python3.11 -m venv $VIRTUAL_ENV && \ + + # Install app requirements and nextpy inside virtualenv + pip install --no-cache-dir -r requirements.txt && \ + + # Deploy templates and prepare app + nextpy init && \ + + # Export static copy of frontend to /app/.web/_static + nextpy export --frontend-only --no-zip && \ + + # Copy static files out of /app to save space in backend image + mv .web/_static /tmp/_static && \ + rm -rf .web && mkdir .web && \ + mv /tmp/_static .web/_static # Stage 2: copy artifacts into slim image FROM python:3.11-slim From b14369f0ccc604667154a81f56eb388cc8fa5baf Mon Sep 17 00:00:00 2001 From: anirudh Date: Mon, 15 Apr 2024 20:31:02 +0530 Subject: [PATCH 2/3] altered Dockerfile --- docker-example/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-example/Dockerfile b/docker-example/Dockerfile index 7dc1e5ee..314ed7e0 100644 --- a/docker-example/Dockerfile +++ b/docker-example/Dockerfile @@ -25,7 +25,8 @@ RUN \ # Copy static files out of /app to save space in backend image mv .web/_static /tmp/_static && \ - rm -rf .web && mkdir .web && \ + rm -rf .web && \ + mkdir .web && \ mv /tmp/_static .web/_static # Stage 2: copy artifacts into slim image @@ -37,4 +38,4 @@ COPY --chown=nextpy --from=init /app /app USER nextpy ENV PATH="/app/.venv/bin:$PATH" API_URL=$API_URL -CMD nextpy db migrate && nextpy run --env prod --backend-only +CMD ["sh","-c","nextpy db migrate && nextpy run --env prod --backend-only"] From 0abbc537c797e5f3c0859d156543c1792227b28b Mon Sep 17 00:00:00 2001 From: Anirudh Hegde Date: Tue, 16 Apr 2024 17:34:17 +0530 Subject: [PATCH 3/3] Update Dockerfile --- docker-example/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-example/Dockerfile b/docker-example/Dockerfile index 314ed7e0..da1a39b0 100644 --- a/docker-example/Dockerfile +++ b/docker-example/Dockerfile @@ -38,4 +38,4 @@ COPY --chown=nextpy --from=init /app /app USER nextpy ENV PATH="/app/.venv/bin:$PATH" API_URL=$API_URL -CMD ["sh","-c","nextpy db migrate && nextpy run --env prod --backend-only"] +CMD nextpy db migrate && nextpy run --env prod --backend-only