Files
InvoiceShelf/docker/development/nginx.Dockerfile
Darko Gjorgjijoski 2f641ace0e build: migrate frontend tooling to pnpm + pin vite 8.0.3 (#666)
* build: migrate frontend tooling from yarn to pnpm

The Dockerfiles ran `yarn && yarn build`, which broke on node:24 (yarn no
longer on PATH; the corepack yarn shim made `npm i -g yarn` fail EEXIST),
while CI + Makefile used npm and only a yarn.lock was committed — an
inconsistent yarn/npm split. Standardize on pnpm, pinned via the
packageManager field + corepack.

- package.json: packageManager pnpm@11.6.0.
- pnpm-workspace.yaml: nodeLinker: hoisted (flat node_modules, npm/yarn-like, so
  directly-imported transitive deps like flatpickr resolve) + allow vue-demi's
  postinstall (it selects the Vue 3 entry). pnpm 11 reads these here, not .npmrc.
- Generate pnpm-lock.yaml (imported from yarn.lock); delete yarn.lock.
- Dockerfiles (dev/nginx/production): node:24 + `corepack enable && pnpm install --frozen-lockfile && pnpm build`.
- CI (check.yaml, docker.yaml): pnpm/action-setup + setup-node cache:pnpm; pnpm install --frozen-lockfile / pnpm build.
- Makefile, composer.json dev script, CLAUDE.md: npm/yarn -> pnpm.

pnpm build verified on a clean install (1425 modules, hoisted node_modules).

* fix(build): pin vite to 8.0.3 to fix rolldown chunk regression

vite 8.0.16 (pulled in by #653) bundles rolldown 1.0.3, which emits a
lazy chunk referencing an undefined Vue runtime-init function
(init_runtime_dom_esm_bundler), breaking the SPA at runtime. The build
succeeds so CI never caught it. Pin vite to 8.0.3 (the version 2.3.3
shipped, rolldown 1.0.0) which produces a correct bundle.
2026-06-12 09:31:08 +02:00

58 lines
1.7 KiB
Docker

FROM --platform=$BUILDPLATFORM node:24 AS static_builder
WORKDIR /var/www/html
COPY . /var/www/html
# corepack activates the pnpm version pinned in package.json's packageManager field.
RUN corepack enable && pnpm install --frozen-lockfile && pnpm build
FROM nginx AS production
ENV PHP_FPM_HOST="php-fpm:9000"
COPY --chown=www-data:www-data . /var/www/html
COPY --from=static_builder --chown=www-data:www-data /var/www/html/public /var/www/html/public
# Map the PHP-FPM host from the PHP_FPM_HOST environment variable to an nging variable
RUN mkdir /etc/nginx/templates && cat <<EOF > /etc/nginx/templates/20-invoiceshelf.conf.template
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/public;
# Set allowed "index" files
index index.html index.htm index.php;
server_name _;
charset utf-8;
# Set max upload to 2048M
client_max_body_size 2048M;
# Healthchecks: Set /healthcheck to be the healthcheck URL
location /healthcheck {
access_log off;
# set max 5 seconds for healthcheck
fastcgi_read_timeout 5s;
include fastcgi_params;
fastcgi_param SCRIPT_NAME /healthcheck;
fastcgi_param SCRIPT_FILENAME /healthcheck;
fastcgi_pass \${PHP_FPM_HOST};
}
# Have NGINX try searching for PHP files as well
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
# Pass "*.php" files to PHP-FPM
location ~ \.php\$ {
fastcgi_pass \${PHP_FPM_HOST};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 8 8k;
fastcgi_buffer_size 8k;
}
}
EOF