Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Dockerfile #156

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions docker-example/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ 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
Expand All @@ -36,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"]
anirudh-hegde marked this conversation as resolved.
Show resolved Hide resolved
Loading