Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 42 additions & 41 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
# Use the official Node.js image as the base image
FROM node:20

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Copy workspace package.json files for proper monorepo setup
COPY packages/utils/package.json ./packages/utils/
COPY packages/yasgui/package.json ./packages/yasgui/
COPY packages/yasqe/package.json ./packages/yasqe/
COPY packages/yasr/package.json ./packages/yasr/

# Install dependencies (skip puppeteer download to avoid network errors)
ENV PUPPETEER_SKIP_DOWNLOAD=1
RUN npm ci

# Copy the rest of the application code
COPY . .

# Build the app
RUN npm run build

# Use the official Nginx image to serve the React app
FROM nginxinc/nginx-unprivileged:alpine

# Copy only JS/CSS from the build output
COPY --from=0 /app/build/yasgui.min.js /usr/share/nginx/html/
COPY --from=0 /app/build/yasgui.min.css /usr/share/nginx/html/

# Copy other static assets
COPY docker/src/ /usr/share/nginx/html/

USER root

COPY docker/change-default-endpoint.sh /docker-entrypoint.d/
RUN chmod +x /docker-entrypoint.d/change-default-endpoint.sh
RUN chown 1001:0 -R /usr/share/nginx/html/

# Use the official Node.js image as the base image
FROM node:20

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Copy workspace package.json files for proper monorepo setup
COPY packages/utils/package.json ./packages/utils/
COPY packages/yasgui/package.json ./packages/yasgui/
COPY packages/yasqe/package.json ./packages/yasqe/
COPY packages/yasr/package.json ./packages/yasr/

# Install dependencies (skip puppeteer download to avoid network errors)
ENV PUPPETEER_SKIP_DOWNLOAD=1
RUN npm ci

# Copy the rest of the application code
COPY . .

# Build the app
RUN npm run build

# Use the official Nginx image to serve the React app
FROM nginxinc/nginx-unprivileged:alpine

# Copy only JS/CSS from the build output, plus the fonts and images the CSS references
COPY --from=0 /app/build/yasgui.min.js /usr/share/nginx/html/
COPY --from=0 /app/build/yasgui.min.css /usr/share/nginx/html/
COPY --from=0 /app/build/yasgui-*.woff2 /app/build/yasgui-*.png /usr/share/nginx/html/

# Copy other static assets
COPY docker/src/ /usr/share/nginx/html/

USER root

COPY docker/change-default-endpoint.sh /docker-entrypoint.d/
RUN chmod +x /docker-entrypoint.d/change-default-endpoint.sh
RUN chown 1001:0 -R /usr/share/nginx/html/

USER 1001
11 changes: 8 additions & 3 deletions esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ function removeExtraCss(result) {
}

async function buildPackage(name, entryPoint, globalName) {
// Prefix emitted assets (fonts, images) with the package name so that
// distributeBuildFiles.js, which copies `build/<name>*` into each package,
// also ships the files the CSS references.
const assetConfig = { ...commonConfig, assetNames: `${name}-[name]-[hash]` };

// IIFE build: exposes a browser global (e.g. `window.Yasgui`) for <script> usage.
const iifeResult = await esbuild.build({
...commonConfig,
...assetConfig,
entryPoints: [entryPoint],
outfile: `build/${name}.min.js`,
format: "iife",
Expand All @@ -145,7 +150,7 @@ async function buildPackage(name, entryPoint, globalName) {
// ESM build: consumed by bundlers (vite/webpack/esbuild) and Node via `import`.
// Uses the `.mjs` extension so it is always treated as an ES module.
const esmResult = await esbuild.build({
...commonConfig,
...assetConfig,
entryPoints: [entryPoint],
outfile: `build/${name}.mjs`,
format: "esm",
Expand All @@ -157,7 +162,7 @@ async function buildPackage(name, entryPoint, globalName) {
// CJS build: consumed by Node's `require`. Uses the `.cjs` extension so it is
// always treated as CommonJS regardless of the nearest package.json `type`.
const cjsResult = await esbuild.build({
...commonConfig,
...assetConfig,
entryPoints: [entryPoint],
outfile: `build/${name}.cjs`,
format: "cjs",
Expand Down
Loading