Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31038 closed Bug (invalid)

Prevent collectstatic from trying to access a database.

Reported by: Stefan Völkl Owned by: nobody
Component: contrib.staticfiles Version: 2.2
Severity: Normal Keywords: collectstatic
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Stefan Völkl)

I have a Dockerfile with a multi-stage build in which I'm trying to run collectstatic to get all the static files and copy them into the final docker image.
At this moment I don't have a database to access, but as collectstatic is trying to access one with dummy values, I get an error.

In my opinion there should be no need for collectstatic to access a database. I have read through other Issues concerning this, so I think you are not planning on changing this. That's why I need to know if there is any way to prevent this access to a database.

Here's what I have:

ARG baseImage
FROM ${baseImage} AS base

USER root

ENV DB_HOST="example" \
    DB_NAME="example" \
    DB_USER="example" \
    DB_PASSWORD="example"

RUN python app/manage.py collectstatic --skip-checks --noinput --clear \
    && node_modules/.bin/gulp compile --destination "/tmp/staticcmp"


FROM nginx:1.11 AS cdn

COPY docker/cdn/etc/cdn-nginx.conf /etc/nginx/conf.d/default.template
COPY docker/cdn/robots.txt /usr/share/nginx/html/robots.txt
COPY docker/cdn/bin/ /usr/local/bin/
COPY --from=base /tmp/staticcmp/ /usr/share/nginx/html/static

ENV NGINX_ERROR_LOG="/dev/stdout" \
    NGINX_ACCESS_LOG="/dev/stdout"

EXPOSE 8000

ENTRYPOINT ["docker-cdn-entrypoint"]

Change History (4)

comment:1 by Stefan Völkl, 5 years ago

Description: modified (diff)
Type: UncategorizedBug

comment:2 by Stefan Völkl, 5 years ago

Description: modified (diff)

comment:3 by Mariusz Felisiak, 5 years ago

Resolution: invalid
Status: newclosed
Summary: prevent collectstatic from trying to access a databaseprevent collectstatic from trying to access a database.

Please don't use Trac as a support channel.

Closing per TicketClosingReasons/UseSupportChannels.

comment:4 by Mariusz Felisiak, 5 years ago

Summary: prevent collectstatic from trying to access a database.Prevent collectstatic from trying to access a database.
Note: See TracTickets for help on using tickets.
Back to Top