Skip to content

Commit

Permalink
Build Kinto Admin from source (#2966)
Browse files Browse the repository at this point in the history
* Build Kinto Admin from source

Instead of using the `<KintoAdmin />` React component and mounting that
in a create-react-app project, when we build `kinto`, we download the source
code of `kinto-admin`, build it, and move the build folder to the plugin.

* Point Kinto Admin version to 2.0.0 release

* Add entry to changelog
  • Loading branch information
grahamalama authored Mar 23, 2022
1 parent a4e529a commit 8527385
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 44,086 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ config/*.ini
version.json
dist
kinto/plugins/admin/build
kinto/plugins/admin/node_modules
kinto/plugins/admin/coverage
kinto/plugins/admin/npm-debug.log
kinto/plugins/admin/kinto-admin-*
.pytest_cache/
mail/
.history/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This document describes changes between each past release.
**Internal Changes**

- Test package description formatting in CI
- Build ``kinto-admin`` (now at version 2.0.0) from source rather than mounting the ``<KintoAdmin />`` component in a ``create-react-app`` app. (#2966)


14.6.1 (2022-02-03)
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Mozilla Kinto server

FROM node:lts-bullseye-slim as node-builder
COPY /kinto/plugins/admin/package.json /kinto/plugins/admin/package-lock.json ./
RUN npm ci
COPY /kinto/plugins/admin ./
RUN npm run build
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl
COPY scripts/build-kinto-admin.sh .
COPY /kinto/plugins/admin ./kinto/plugins/admin
RUN bash build-kinto-admin.sh

FROM python:3.10-slim-bullseye as python-builder
RUN python -m venv /opt/venv
Expand All @@ -23,7 +23,7 @@ RUN groupadd --gid 10001 app && \
WORKDIR /app
COPY --from=python-builder /opt/venv /opt/venv
COPY . /app
COPY --from=node-builder /build ./kinto/plugins/admin/build
COPY --from=node-builder /kinto/plugins/admin/build ./kinto/plugins/admin/build

ENV KINTO_INI=/etc/kinto/kinto.ini \
PORT=8888 \
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ include kinto/config/kinto.tpl
recursive-include kinto *.sql *.html *.ini *.yaml
recursive-include docs *.rst *.png *.svg *.css *.html conf.py piwik.js
recursive-include kinto/plugins/admin/build *
include kinto/plugins/admin/package.json
prune docs/_build/*
prune kinto/plugins/admin/node_modules/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $(PYTHON):
$(VIRTUALENV) $(VENV)

build-kinto-admin: need-npm
cd kinto/plugins/admin/; npm ci && export REACT_APP_VERSION="$$(npm list | egrep kinto-admin | cut -d @ -f 2)" && npm run build
scripts/build-kinto-admin.sh

$(SERVER_CONFIG):
$(VENV)/bin/kinto init --ini $(SERVER_CONFIG)
Expand Down
3 changes: 1 addition & 2 deletions kinto/plugins/admin/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# kinto-admin plugin setup

Update the `kinto-admin` version you want in the `dependencies` section of the
`package.json` file.
Update the `kinto-admin` version you want in the VERSION file of this plugin
1 change: 1 addition & 0 deletions kinto/plugins/admin/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0
12 changes: 3 additions & 9 deletions kinto/plugins/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import os
from pathlib import Path

from pyramid.httpexceptions import HTTPTemporaryRedirect
from pyramid.static import static_view

from kinto.core.utils import json

from .views import admin_home_view

HERE = os.path.dirname(__file__)
VERSION_FILE_PATH = Path(__file__).parent / "VERSION"


def includeme(config):
# Process settings to remove storage wording.

# Read version from package.json
package_json = json.load(open(os.path.join(HERE, "package.json")))
admin_version = package_json["dependencies"]["kinto-admin"]
admin_version = VERSION_FILE_PATH.read_text().strip()

# Expose capability.
config.add_api_capability(
Expand Down
Loading

0 comments on commit 8527385

Please sign in to comment.