green-ability-63757
09/22/2022, 3:52 PM404
) when I run a shell script (shell_sources
) that among other things executes collectstatic
This is only happening when I run the docker version. Here’s how the Dockerfile
looks like
FROM python:3.10-slim
### Arg
ARG DEBIAN_FRONTEND=noninteractive
### Env
ENV APP_HOST=.
ENV APP_DOCKER=/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY twoops_tracker.py/main.pex /bin/dj
# Expose server port
EXPOSE 8000
### Volumes
WORKDIR ${APP_DOCKER}
RUN mkdir -p media staticfiles logs
COPY twoops_tracker/sh/*.sh /
RUN chmod +x /cmd.sh
### Run app
CMD ["/cmd.sh"]
I’ve also noticed that the files are being saved under
/root/.pex/user_code/a517e67b58e274b35127ae63804115e6156bfe3d/staticfiles
which I think is the reason why they can’t be found.
Any ideas on how I can solve this?happy-kitchen-89482
09/22/2022, 4:11 PMmain.pex
with some version of Pants, and then running it in a container?green-ability-63757
09/22/2022, 4:12 PMgreen-ability-63757
09/22/2022, 4:15 PMBuild
for the docker
docker_image(
name = "twoops-tracker",
dependencies = [
"twoops_tracker/py:main",
"twoops_tracker/sh:sh",
],
image_tags = [
"{build_args.VERSION}",
"latest",
],
)
happy-kitchen-89482
09/22/2022, 4:23 PMgreen-ability-63757
09/22/2022, 4:25 PMhappy-kitchen-89482
09/22/2022, 4:28 PMsources
of a resources
or files
target? How are they getting into the pex?green-ability-63757
09/22/2022, 4:33 PMhappy-kitchen-89482
09/22/2022, 5:02 PMhappy-kitchen-89482
09/22/2022, 5:02 PMhappy-kitchen-89482
09/22/2022, 5:02 PMgreen-ability-63757
09/22/2022, 5:04 PMgreen-ability-63757
09/22/2022, 7:17 PMSTATIC_ROOT
which was previously being based on BASE_DIR = Path(__file__).resolve().parent.parent
which was causing the issue.happy-kitchen-89482
09/22/2022, 8:52 PMhappy-kitchen-89482
09/22/2022, 8:53 PMgreen-ability-63757
09/23/2022, 5:49 AMcollectstatic
command in order to have all static files from different apps into one location. From there we just configure Nginx or any webserver to respond to /static
request with files from the location where collectstatic
saved the files.
Just to note, for our case we store the files in S3 but we still wanted to be able to run the docker image locally without having to use the s3 files.happy-kitchen-89482
09/23/2022, 1:06 PMcollectstatic
typically collects the static files from your source tree.happy-kitchen-89482
09/23/2022, 1:06 PMgreen-ability-63757
09/23/2022, 7:54 PMpex
file include the django
static files?happy-kitchen-89482
09/23/2022, 8:09 PMhappy-kitchen-89482
09/23/2022, 8:09 PMcollectstatic
is a Django utility that gathers your static files from all over your codebase and dumps them into a single dir for serving purposeshappy-kitchen-89482
09/23/2022, 8:09 PMhappy-kitchen-89482
09/23/2022, 8:10 PMhappy-kitchen-89482
09/23/2022, 8:10 PMgreen-ability-63757
09/26/2022, 9:49 AM