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

Fixes #3380 - UI asset files not properly copied to container #3381

Merged
merged 6 commits into from
Feb 2, 2024

Conversation

alexcottner
Copy link
Contributor

Fixes #3380 - UI files not properly copied to container.
Also pulling the pre-built single-server files going forward to make things easier.

  • Add documentation.

MANIFEST.in Outdated
@@ -0,0 +1 @@
recursive-include kinto/plugins/admin/build *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now managed here

kinto/pyproject.toml

Lines 54 to 55 in b67c6c3

[tool.setuptools.package-data]
"*" = ["*.tpl", "*.sql", "*.html", "VERSION"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that explains why the index.html file was showing up but nothing else.

@alexcottner alexcottner marked this pull request as ready for review February 2, 2024 15:43
pyproject.toml Outdated
@@ -52,7 +52,7 @@ main = "kinto:main"
include = ["kinto*"]

[tool.setuptools.package-data]
"*" = ["*.tpl", "*.sql", "kinto/plugins/admin/build/*", "VERSION"]
"*" = ["*.tpl", "*.sql", "*.html", "*.css", "*.js", "*.png", "VERSION"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinto/plugins/admin/build/*

Did this only include index.html? Would a glob of kinto/plugins/admin/build/**/* work? If so, I think that'd also take care of VERSION

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found the pattern that works best I think:
plugins/admin/build/**

Dockerfile Outdated
FROM python:3.10-slim-bullseye as python-builder
RUN python -m venv /opt/venv
RUN apt-get update && apt-get install -y --no-install-recommends build-essential libpq-dev
RUN apt-get update && apt-get install -y --no-install-recommends build-essential libpq-dev ca-certificates curl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the base container to FROM python:3.10 instead? That way we can get rid of this entire line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, makes building faster too.

Comment on lines +13 to +14
COPY scripts/pull-kinto-admin.sh .
RUN bash pull-kinto-admin.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to find a way to do this before we COPY kinto/ kinto/. Right now, any time we modify a Kinto source file, we'll have to redownload kinto-admin. We really only need to redownload Kinto Admin when VERSION changes.

Maybe we can pull kinto admin an earlier layer, then copy the files to the right place after we copy the kinto directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a change to do that, but it's a little janky because it's working around a circular dependency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, you can leave it for now then -- since we're just curling, it's much faster that having to do a whole build step.

Dockerfile Outdated
ARG KINTO_VERSION=1
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_KINTO=${KINTO_VERSION} \
PATH="/opt/venv/bin:$PATH"
# At this stage we only fetch and build all dependencies.
WORKDIR /pkg-kinto
COPY constraints.txt .
COPY pyproject.toml .
COPY constraints.txt pyproject.toml ./
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could pip install --upgrade pip && pip install -r constraints.txt after this layer, again for cache preservation purposes.

Similar to my other comment, right now, any time we change a Kinto source file, we'll need to upgrade pip, then reinstall all of the dependencies. If we move this step up here, we'll only need to do that when constraints.txt or pyproject.toml change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added


# download and unzip release
curl -OL "https://github.com/Kinto/kinto-admin/releases/download/${TAG}/kinto-admin-release.tar"
rm -r ./kinto/plugins/admin/build || echo "admin/build folder doesn't exist yet"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rm -r ./kinto/plugins/admin/build || echo "admin/build folder doesn't exist yet"
rm -rf ./kinto/plugins/admin/build

Or is this too dangerous?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this script was only used for docker I'd be fine with the -f but the echo makes me feel better when running it through make on my machine. I don't think it's really dangerous though.

rm -r ./kinto/plugins/admin/build || echo "admin/build folder doesn't exist yet"
mkdir ./kinto/plugins/admin/build
tar -xf kinto-admin-release.tar -C ./kinto/plugins/admin/build && rm kinto-admin-release.tar
echo "$VERSION" > ./kinto/plugins/admin/build/VERSION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe write a comment here that after Kinto/kinto-admin@8400176 is deployed, we don't have to do this step?

@alexcottner alexcottner merged commit 039d3e3 into main Feb 2, 2024
19 checks passed
@alexcottner alexcottner deleted the fix-docker-ui-build branch February 2, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Building and running docker locally causes the UI to not load
3 participants