Skip to content

Commit

Permalink
Fix Webpack 4 build
Browse files Browse the repository at this point in the history
Remove npm-packages
  • Loading branch information
sbrunner committed Sep 26, 2024
1 parent f7eeb31 commit 87e875c
Show file tree
Hide file tree
Showing 14 changed files with 6,992 additions and 1,059 deletions.
18 changes: 5 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ COPY scripts/extract-messages.js /opt/c2cgeoportal/geoportal/

ENV TEST=false
ENV PATH=/opt/c2cgeoportal/geoportal/node_modules/.bin:$PATH
ENV NODE_PATH=/opt/c2cgeoportal/geoportal/node_modules

#############################################################################################################
# Finally used for all misk task, will not be used on prod runtime
Expand All @@ -88,7 +89,6 @@ FROM base AS tools

SHELL ["/bin/bash", "-o", "pipefail", "-cux"]

ENV NODE_PATH=/usr/lib/node_modules
CMD ["tail", "--follow", "--zero-terminated", "/dev/null"]

RUN --mount=type=cache,target=/var/lib/apt/lists \
Expand Down Expand Up @@ -116,23 +116,15 @@ WORKDIR /opt/c2cgeoportal
COPY ci/applications*.yaml .
RUN c2cciutils-download-applications --applications-file=applications.yaml --versions-file=applications-versions.yaml

COPY bin/npm-packages /usr/bin/
WORKDIR /opt/c2cgeoportal/geoportal
COPY geoportal/package.json geoportal/package-lock.json geoportal/.snyk ./

# hadolint ignore=DL3016,SC2046
RUN --mount=type=cache,target=/var/cache,sharing=locked \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp \
npm install --omit=optional \
&& npm-packages \
@types @typescript-eslint @storybook ol-cesium jasmine-core karma karma-chrome-launcher \
karma-jasmine karma-sinon karma-sourcemap-loader karma-webpack \
react react-dom cypress chromatic jscodeshift start-server-and-test \
typedoc typescript \
angular-gettext-tools commander puppeteer url-parse eslint \
--src=package.json --src=node_modules/ngeo/package.json --dst=npm-packages \
&& npm install --omit=optional --global --unsafe-perm $(cat /opt/c2cgeoportal/geoportal/npm-packages)
npm --ignore-scripts install \
&& puppeteer browsers install chrome

COPY admin/package.json admin/package-lock.json admin/.snyk /opt/c2cgeoportal/admin/
WORKDIR /opt/c2cgeoportal/admin
Expand Down Expand Up @@ -161,10 +153,10 @@ COPY build.mk lingva.cfg ./

RUN make --makefile=build.mk build \
&& mkdir -p 'geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/geoportal/interfaces/' \
&& import-ngeo-apps --html --canvas desktop_alt /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop_alt/index.html.ejs \
&& import-ngeo-apps --html --canvas desktop_alt geoportal/node_modules/ngeo/contribs/gmf/apps/desktop_alt/index.html.ejs \
'geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/geoportal/interfaces/desktop_alt.html.mako' \
&& mkdir -p 'geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/geoportal/{{cookiecutter.package}}_geoportal/static/images/' \
&& cp /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop/image/background-layer-button.png \
&& cp geoportal/node_modules/ngeo/contribs/gmf/apps/desktop/image/background-layer-button.png \
'geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/geoportal/{{cookiecutter.package}}_geoportal/static/images/'

COPY commons/ commons/
Expand Down
6 changes: 3 additions & 3 deletions bin/extract-ngeo-dependencies
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright (c) 2018-2023, Camptocamp SA
# Copyright (c) 2018-2024, Camptocamp SA
# All rights reserved.

# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -34,8 +34,8 @@ all_required_js = set()
IMPORT_FROM = re.compile(r"^import +.* +from +'(.*)';$")
ONLY_IMPORT = re.compile(r"^import +'(.*)';$")
for pathname in (
"/usr/lib/node_modules/ngeo/src/**/*.js",
"/usr/lib/node_modules/ngeo/contribs/gmf/src/**/*.js",
"geoportal/node_modules/ngeo/src/**/*.js",
"geoportal/node_modules/ngeo/contribs/gmf/src/**/*.js",
):
for filename in glob.glob(pathname, recursive=True):
with open(filename) as js:
Expand Down
113 changes: 0 additions & 113 deletions bin/npm-packages

This file was deleted.

30 changes: 15 additions & 15 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,72 +46,72 @@ build: \
.PHONY: import-ngeo-apps
import-ngeo-apps: $(API_FILES) $(APPS_FILES) $(APPS_FILES_ALT) $(STATIC_PATH)/header.html

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/%.html.ejs: /usr/lib/node_modules/ngeo/contribs/gmf/apps/%/index.html.ejs
$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/%.html.ejs: geoportal/node_modules/ngeo/contribs/gmf/apps/%/index.html.ejs
mkdir --parent $(dir $@)
import-ngeo-apps --html $* $< $@

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/Controller%.js: /usr/lib/node_modules/ngeo/contribs/gmf/apps/%/Controller.js
$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/Controller%.js: geoportal/node_modules/ngeo/contribs/gmf/apps/%/Controller.js
mkdir --parent $(dir $@)
import-ngeo-apps --js $* $< $@

$(APPS_PACKAGE_PATH_ALT)/static-ngeo/js/apps/%.html.ejs: \
/usr/lib/node_modules/ngeo/contribs/gmf/apps/%/index.html.ejs \
geoportal/node_modules/ngeo/contribs/gmf/apps/%/index.html.ejs \
geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/
mkdir --parent $(dir $@)
import-ngeo-apps --html $* $< $@

$(APPS_PACKAGE_PATH_ALT)/static-ngeo/js/apps/Controller%.js: \
/usr/lib/node_modules/ngeo/contribs/gmf/apps/%/Controller.js \
geoportal/node_modules/ngeo/contribs/gmf/apps/%/Controller.js \
geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/
mkdir --parent $(dir $@)
import-ngeo-apps --js $* $< $@

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/sass/%.scss:
mkdir --parent $(dir $@)
cp /usr/lib/node_modules/ngeo/contribs/gmf/apps/$*/sass/$*.scss $@
cp geoportal/node_modules/ngeo/contribs/gmf/apps/$*/sass/$*.scss $@

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/sass/vars_%.scss:
mkdir --parent $(dir $@)
cp /usr/lib/node_modules/ngeo/contribs/gmf/apps/$*/sass/vars_$*.scss $@
cp geoportal/node_modules/ngeo/contribs/gmf/apps/$*/sass/vars_$*.scss $@

$(APPS_PACKAGE_PATH_ALT)/static-ngeo/js/apps/sass/%.scss: \
geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/
mkdir --parent $(dir $@)
cp /usr/lib/node_modules/ngeo/contribs/gmf/apps/$*/sass/$*.scss $@
cp geoportal/node_modules/ngeo/contribs/gmf/apps/$*/sass/$*.scss $@

$(APPS_PACKAGE_PATH_ALT)/static-ngeo/js/apps/sass/vars_%.scss: \
geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_create_template/
mkdir --parent $(dir $@)
cp /usr/lib/node_modules/ngeo/contribs/gmf/apps/$*/sass/vars_$*.scss $@
cp geoportal/node_modules/ngeo/contribs/gmf/apps/$*/sass/vars_$*.scss $@

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/contextualdata.html: /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop/contextualdata.html
$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/contextualdata.html: geoportal/node_modules/ngeo/contribs/gmf/apps/desktop/contextualdata.html
mkdir --parent $(dir $@)
cp $< $@

$(STATIC_PATH)/header.html: /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop/header.html
$(STATIC_PATH)/header.html: geoportal/node_modules/ngeo/contribs/gmf/apps/desktop/header.html
mkdir --parent $(dir $@)
cp $< $@

$(STATIC_PATH)/images/%: /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop/image/%
$(STATIC_PATH)/images/%: geoportal/node_modules/ngeo/contribs/gmf/apps/desktop/image/%
$(PRERULE_CMD)
mkdir --parent $(dir $@)
cp $< $@

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/image/%: /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop/image/%
$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/image/%: geoportal/node_modules/ngeo/contribs/gmf/apps/desktop/image/%
$(PRERULE_CMD)
mkdir --parent $(dir $@)
cp $< $@

$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/image/%: /usr/lib/node_modules/ngeo/contribs/gmf/apps/desktop_alt/image/%
$(APPS_PACKAGE_PATH)/static-ngeo/js/apps/image/%: geoportal/node_modules/ngeo/contribs/gmf/apps/desktop_alt/image/%
$(PRERULE_CMD)
mkdir --parent $(dir $@)
cp $< $@

$(APPS_PACKAGE_PATH)/static-ngeo/api/api.css: /usr/lib/node_modules/ngeo/api/src/api.css
$(APPS_PACKAGE_PATH)/static-ngeo/api/api.css: geoportal/node_modules/ngeo/api/src/api.css
mkdir --parent $(dir $@)
cp $< $@

$(STATIC_PATH)/apihelp: /usr/lib/node_modules/ngeo/api/dist/apihelp
$(STATIC_PATH)/apihelp: geoportal/node_modules/ngeo/api/dist/apihelp
rm --recursive --force $@
cp -r $< $@
mv $@/apihelp.html $@/index.html.tmpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN make build
RUN mv webpack.apps.js webpack.apps.js.tmpl

ENTRYPOINT [ "/usr/bin/eval-templates" ]
CMD [ "webpack-dev-server", "--mode=development", "--debug", "--watch", "--no-inline" ]
CMD [ "webpack", "serve", "--open", "--mode=development", "--watch", "--no-inline" ]

###############################################################################

Expand All @@ -33,7 +33,8 @@ WORKDIR /app
COPY . /app
# Workaround, see:https://github.com/moby/moby/issues/37965
RUN true
COPY --from=builder /usr/lib/node_modules/ngeo/dist/* /etc/static-ngeo/
COPY --from=builder /opt/c2cgeoportal/geoportal/node_modules/ngeo/dist/* /etc/static-ngeo/
RUN rm /etc/static-ngeo/*.html
COPY --from=builder /etc/static-ngeo/* /etc/static-ngeo/
COPY --from=builder /app/alembic.ini /app/alembic.yaml ./
RUN chmod go+w /etc/static-ngeo/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,17 @@ module.exports = (env, argv) => {
minimizer: [
new TerserPlugin({
parallel: true,
sourceMap: true,
terserOptions: {
compress: false,
},
}),
],
},
resolve: {
modules: [
'/usr/lib/node_modules',
'/usr/lib/node_modules/ol/node_modules',
'/usr/lib/node_modules/proj4/node_modules',
],
modules: ['/opt/c2cgeoportal/geoportal/node_modules'],
alias: {
api: '/usr/lib/node_modules/ngeo/api/src',
ngeo: '/usr/lib/node_modules/ngeo/src',
api: '/opt/c2cgeoportal/geoportal/node_modules/ngeo/distlib/api/src',
ngeo: '/opt/c2cgeoportal/geoportal/node_modules/ngeo/distlib/src',
},
},
resolveLoader: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ module.exports = {
entry: entry,
plugins: plugins,
resolve: {
modules: ['/usr/lib/node_modules'],
modules: ['/opt/c2cgeoportal/geoportal/node_modules/'],
alias: {
'{{cookiecutter.package}}': path.resolve(
__dirname,
'{{cookiecutter.package}}_geoportal/static-ngeo/js'
),
ngeo: '/opt/c2cgeoportal/geoportal/node_modules/ngeo/distlib/src',
gmf: '/opt/c2cgeoportal/geoportal/node_modules/ngeo/distlib/src',
gmfapi: '/opt/c2cgeoportal/geoportal/node_modules/ngeo/distlib/srcapi',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = commons({
DllReferencePluginOptions: {
context: '/usr/lib/',
},
browsers: 'defaults, > 0.1% in CH, > 0.1% in FR, Firefox ESR and supports es6-class and not iOS < 10',
noTs: true,
});

module.exports = () => config;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NGEO_OUTPUT_FILES = $(ANGULAR_LOCALES_FILES)
NGEO_API_OUTPUT_JS_FILE ?= $(APP_OUTPUT_DIR)/api.js.tmpl
NGEO_API_OUTPUT_FILES += $(NGEO_API_OUTPUT_JS_FILE) $(APP_OUTPUT_DIR)/api.css

WEBPACK_ARGS ?= --debug
WEBPACK_ARGS ?=

VALIDATE_PY_FOLDERS = admin/$(PACKAGE)_admin \
$(PACKAGE)_geoportal/*.py $(PACKAGE)_geoportal/lib \
Expand Down Expand Up @@ -83,12 +83,12 @@ update-po: update-server-po update-client-po
.PHONY: build-ngeo
build-ngeo: $(NGEO_OUTPUT_FILES)

$(APP_OUTPUT_DIR)/angular-locale_%.js: /usr/lib/node_modules/ngeo/package.json language_mapping
$(APP_OUTPUT_DIR)/angular-locale_%.js: /opt/c2cgeoportal/geoportal/node_modules/ngeo/package.json language_mapping
mkdir --parent $(dir $@)
rm --force $@
cp /opt/angular-locale/angular-locale_`(grep $* language_mapping || echo $*) | cut --delimiter = --fields 2 | tr --delete '\r\n'`.js $@

$(APP_OUTPUT_DIR)/images/: /usr/lib/node_modules/jquery-ui/themes/base/images
$(APP_OUTPUT_DIR)/images/: /opt/c2cgeoportal/geoportal/node_modules/jquery-ui/themes/base/images
mkdir --parent $@
cp -r $</* $@

Expand All @@ -110,7 +110,7 @@ apps: webpack.apps.js
build-api: $(NGEO_API_OUTPUT_FILES)

$(APP_OUTPUT_DIR)/api.js.tmpl: webpack.api.js $(PACKAGE)_geoportal/static-ngeo/api/index.js
webpack --config webpack.api.js $(WEBPACK_ARGS)
webpack --config=webpack.api.js $(WEBPACK_ARGS)
cp $(APP_OUTPUT_DIR)/api.js $(APP_OUTPUT_DIR)/api.js_
sed --in-place --expression='s/\$$/$${DOLLAR}/g' $(APP_OUTPUT_DIR)/api.js
sed --in-place --expression='s#{FULL_ENTRY_POINT}#$${VISIBLE_WEB_PROTOCOL}://$${VISIBLE_WEB_HOST}$${VISIBLE_ENTRY_POINT}#g' $(APP_OUTPUT_DIR)/api.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ services:
# # Adapt the path for ngeo / gmf contrib to point where you have checkouted the code.
# # volumes:
# # - ./geoportal/${PACKAGE}_geoportal/static-ngeo:/app/${PACKAGE}_geoportal/static-ngeo
# # - ./../ngeo/src:/usr/lib/node_modules/ngeo/src
# # - ./../ngeo/contribs:/usr/lib/node_modules/ngeo/contribs
# # - ./../ngeo/src:/opt/c2cgeoportal/geoportal/node_modules/ngeo/src
# # - ./../ngeo/contribs:/opt/c2cgeoportal/geoportal/node_modules/ngeo/contribs
# volumes_from:
# - config:rw
# extends:
Expand Down
Loading

0 comments on commit 87e875c

Please sign in to comment.