-
-
Notifications
You must be signed in to change notification settings - Fork 0
Improve docker #1027
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
Improve docker #1027
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # .dockerignore is used to exclude files and directories from being copied into the Docker image during the build process. This helps to reduce the size of the image and improve build times by only including necessary files. | ||
| # keep it at the root of the project to ensure that we don't copy unnecessary files into the Docker image. | ||
|
|
||
| node_modules | ||
| **/.turbo | ||
| **/.cache | ||
| **/apps/*/.next | ||
| **/packages/*/dist | ||
| **/packages/*/docs | ||
| **/.eslintcache |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,7 @@ npmPreapprovedPackages: | |
| - ws | ||
| - "@vitest/*" | ||
| - "shadcn" | ||
| - "@oxc-project/*" | ||
|
|
||
| npmPublishProvenance: true | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,10 @@ | ||
| # this file should won't be read unless it exists in the | ||
| # context directory specified in the docker compose file | ||
|
|
||
| node_modules | ||
| **/node_modules | ||
| #**/.turbo | ||
| #**/.cache | ||
| #**/apps/*/.next | ||
| #**/packages/*/dist | ||
| #**/packages/*/docs | ||
| #**/.eslintcache |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,12 +7,12 @@ ARG ALPINE_VERSION=3.23 | |||||
|
|
||||||
| FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS app-builder | ||||||
|
|
||||||
| # gcompat is required for duckdb neo to work | ||||||
| RUN apk add --no-cache git jq && corepack enable | ||||||
| # You might want to add gcompat for duckdb neo to work | ||||||
| RUN apk add --no-cache git jq && rm -rf /var/cache/apk/* && npm i -g corepack && corepack enable | ||||||
|
|
||||||
| WORKDIR /app | ||||||
|
|
||||||
| COPY --link package.json turbo.json ./ | ||||||
| COPY --link package.json turbo.jsonc ./ | ||||||
|
|
||||||
| # We can't run turbo without yarn install first, let's install locally and make sure | ||||||
| # both local and docker are aligned on the package.json version. | ||||||
|
|
@@ -39,7 +39,7 @@ ENV NEXT_BUILD_ENV_OUTPUT=standalone | |||||
| # ENV NEXT_BUILD_ENV_SENTRY_ENABLED=false | ||||||
| # ENV NEXT_BUILD_ENV_SENTRY_TRACING=false | ||||||
|
|
||||||
| ENV TZ=Europe/Brussels | ||||||
| ENV TZ=Etc/UTC | ||||||
|
|
||||||
| # Optimize for YARN installation speed | ||||||
| ENV YARN_ENABLE_GLOBAL_CACHE=false | ||||||
|
|
@@ -70,8 +70,8 @@ RUN yarn install --inline-builds | |||||
| # yarn install --inline-builds | ||||||
|
|
||||||
| # Build the project | ||||||
| COPY --from=app-builder /app/out/nextjs-app/full/ . | ||||||
| COPY --link .gitignore turbo.json tsconfig.base.json ./ | ||||||
| COPY --link --from=app-builder /app/out/nextjs-app/full/ . | ||||||
| COPY --link .gitignore turbo.jsonc tsconfig.base.json ./ | ||||||
|
|
||||||
| RUN yarn workspace @examples/db-sqlserver prisma-generate | ||||||
| RUN yarn turbo run build --filter=@examples/nextjs-app... | ||||||
|
|
@@ -87,9 +87,10 @@ ARG NEXTJS_APP_PORT | |||||
| # Bort PORT / HOSTNAME envs are respected by nextjs start/dev. | ||||||
| ENV HOSTNAME=0.0.0.0 | ||||||
| ENV PORT=${NEXTJS_APP_PORT:-3000} | ||||||
| ENV TZ=Europe/Brussels | ||||||
|
|
||||||
| RUN apk add --no-cache tzdata bash && corepack enable | ||||||
| ENV TZ=Etc/UTC | ||||||
|
|
||||||
| RUN apk add --no-cache tzdata && rm -rf /var/cache/apk/* && npm i -g corepack && corepack enable | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The runner stage installs and enables This adds unnecessary layer weight and inconsistency between the two Dockerfiles. Consider aligning with the Debian runner:
Suggested change
|
||||||
|
|
||||||
| WORKDIR /app | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
|
|
||
| ### Requirements | ||
|
|
||
| - [x] [docker-engine](https://docs.docker.com/get-docker) >= 23 and [buildkit](https://docs.docker.com/build/buildkit/). | ||
| - [x] docker compose v2: [repo](https://github.com/docker/compose) - [docs](https://docs.docker.com/compose/) | ||
| - [x] optional: [lazydocker](https://github.com/jesseduffield/lazydocker), a beautiful tui. | ||
| - [x] optional: [dive](https://github.com/wagoodman/dive) to debug layer sizes. | ||
|
|
@@ -11,9 +10,13 @@ | |
|
|
||
| ```bash | ||
| cd ./docker | ||
| docker compose build | ||
| docker compose build --progress=plain # More verbose | ||
| docker compose build --parallel # Might be faster | ||
| docker buildx bake --file docker-compose.yml | ||
|
|
||
| # Alternatives | ||
| # docker compose build | ||
| # docker compose build --progress=plain # More verbose | ||
| # docker compose build --parallel # Might be faster | ||
|
|
||
| docker compose up | ||
| docker compose down | ||
| ``` | ||
|
|
@@ -23,15 +26,15 @@ docker compose down | |
| #### Run bash in container | ||
|
|
||
| ```bash | ||
| docker compose run nextjs-app bash | ||
| docker compose run nextjs-app bash | ||
| # equivalent to | ||
| docker run --rm -it --entrypoint bash flowblade-nextjs-app-nextjs-app | ||
|
Comment on lines
+29
to
31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the “equivalent” image name with the new exported image tag. Line 31 still references the old image naming, while Line 37 now uses 🛠️ Suggested doc fix-docker run --rm -it --entrypoint bash flowblade-nextjs-app-nextjs-app
+docker run --rm -it --entrypoint bash flowblade-example-nextjs-appAlso applies to: 37-37 🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| #### Get the exported size | ||
|
|
||
| ```bash | ||
| export IMAGE=flowblade-nextjs-app | ||
| export IMAGE=flowblade-example-nextjs-app-debian | ||
|
|
||
| # Inspect the image | ||
| docker image inspect ${IMAGE} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: flowblade-example-nextjs | ||
| services: | ||
| app-alpine: | ||
| build: | ||
| # Start from root of the monorepo | ||
| context: ../../../../ | ||
| dockerfile: ./examples/apps/nextjs-app/docker/Dockerfile.alpine | ||
| restart: no | ||
| networks: | ||
| - flowblade-net | ||
| ports: | ||
| - 3000:3000 | ||
|
|
||
| networks: | ||
| flowblade-net: | ||
| driver: bridge | ||
| enable_ipv6: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| name: flowblade-nextjs-app | ||
| name: flowblade-example-nextjs | ||
| services: | ||
| nextjs-app: | ||
| app-debian: | ||
|
Comment on lines
+1
to
+3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update Docker README examples to match renamed service/project. The compose rename to 🤖 Prompt for AI Agents |
||
| build: | ||
| # Start from root of the monorepo | ||
| context: ../../../../ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,10 +34,12 @@ | |
| "lint": "next typegen && eslint . --ext .ts,.tsx,.js,.jsx,.mjs,.cjs,.mts,.cts --cache --cache-location ../../../.cache/eslint/nextjs-app.eslintcache", | ||
| "fix-staged": "lint-staged --allow-empty", | ||
| "codegen": "run-s codegen-api", | ||
| "codegen-api": "tsx ./scripts/codegen-openapi-json-schema.ts && kubb generate" | ||
| "codegen-api": "tsx ./scripts/codegen-openapi-json-schema.ts && kubb generate", | ||
| "docker-build": "cd docker && docker buildx bake --file ./docker-compose.yml", | ||
| "docker-build-alpine": "cd docker && docker buildx bake --file ./docker-compose.alpine.yml" | ||
| }, | ||
| "dependencies": { | ||
| "@duckdb/duckdb-wasm": "1.31.0", | ||
| "@duckdb/duckdb-wasm": "1.33.1-dev20.0", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Confirm declared version
rg -n "\"@duckdb/duckdb-wasm\"" examples/apps/nextjs-app/package.json -C1
# Inspect DuckDB WASM API touchpoints that are sensitive to SDK changes
rg -n "from '@duckdb/duckdb-wasm'|AsyncDuckDB|DuckDBConfig|getJsDelivrBundles|selectBundle|instantiate\\(|AsyncDuckDBConnection|\\.connect\\(|\\.query\\(" \
examples/apps/nextjs-app/src -C2Repository: belgattitude/flowblade Length of output: 8440 🌐 Web query:
💡 Result: No documented breaking or behavioral changes specific to Citations:
Prefer stable releases over prerelease versions for runtime dependencies with direct API usage. Line 42 upgrades to 🤖 Prompt for AI Agents |
||
| "@duckdb/node-api": "1.5.0-r.1", | ||
| "@examples/base-auth": "workspace:^", | ||
| "@examples/base-ui": "workspace:^", | ||
|
|
@@ -52,19 +54,19 @@ | |
| "@hono/node-server": "1.19.11", | ||
| "@hono/standard-validator": "0.2.2", | ||
| "@httpx/assert": "0.16.8", | ||
| "@httpx/compress": "0.3.11", | ||
| "@httpx/compress": "0.3.12", | ||
| "@httpx/dsn-parser": "1.9.9", | ||
| "@httpx/encode": "0.1.8", | ||
| "@httpx/exception": "3.1.9", | ||
| "@httpx/hash": "0.2.5", | ||
| "@httpx/jwt-verify": "0.2.1", | ||
| "@httpx/lru": "0.13.1", | ||
| "@httpx/md5": "1.0.2", | ||
| "@httpx/jwt-verify": "0.2.2", | ||
| "@httpx/lru": "0.13.2", | ||
| "@httpx/md5": "1.0.3", | ||
| "@httpx/memo-intl": "1.4.10", | ||
| "@httpx/plain-object": "2.1.8", | ||
| "@httpx/stable-hash": "0.3.8", | ||
| "@httpx/treeu": "0.5.8", | ||
| "@httpx/xcache": "0.4.12", | ||
| "@httpx/xcache": "0.5.0", | ||
| "@logtape/logtape": "2.0.4", | ||
| "@logtape/otel": "2.0.4", | ||
| "@logtape/pretty": "2.0.4", | ||
|
|
@@ -99,7 +101,7 @@ | |
| "class-variance-authority": "0.7.1", | ||
| "clsx": "2.1.1", | ||
| "hast-util-to-jsx-runtime": "2.3.6", | ||
| "hono": "4.12.8", | ||
| "hono": "4.12.9", | ||
| "hono-openapi": "1.3.0", | ||
| "json-schema-walker": "3.2.0", | ||
| "ky": "1.14.3", | ||
|
|
@@ -153,8 +155,8 @@ | |
| "@typescript/native-preview": "catalog:", | ||
| "@valibot/to-json-schema": "1.6.0", | ||
| "@vitejs/plugin-react": "6.0.1", | ||
| "@vitest/coverage-v8": "4.1.0", | ||
| "@vitest/ui": "4.1.0", | ||
| "@vitest/coverage-v8": "4.1.1", | ||
| "@vitest/ui": "4.1.1", | ||
| "cross-env": "10.1.0", | ||
| "eslint": "8.57.1", | ||
| "happy-dom": "20.8.4", | ||
|
|
@@ -168,7 +170,7 @@ | |
| "tsx": "4.21.0", | ||
| "tw-animate-css": "1.4.0", | ||
| "typescript": "5.9.3", | ||
| "vitest": "4.1.0" | ||
| "vitest": "4.1.1" | ||
| }, | ||
| "engines": { | ||
| "node": ">=20.19.0" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For official Node.js 24 Alpine Docker images, what is the recommended deterministic approach for Corepack (bundled vs npm-installed), and which Corepack versions are compatible with Node 24?💡 Result:
For official Node.js 24 Alpine Docker images, the bundled Corepack (included with Node.js 24) is the recommended deterministic approach. Run corepack enable to activate the shims for yarn and pnpm. This uses Corepack's predefined "Known Good Releases" for package managers, ensuring consistent versions across builds without network fetches after initial enablement (use corepack prepare for offline determinism). npm-installing Corepack (
@latest, e.g., v0.34.6 as of 2026-01) is not recommended for determinism, as it may introduce version drift and requires extra layers/security considerations; the bundled version matches Node 24 exactly. All Corepack versions compatible with Node >=16.9.0 / >=14.19.0 work with Node 24, but use the bundled one matching Node 24's build.Citations:
🏁 Script executed:
cat -n examples/apps/nextjs-app/docker/Dockerfile.alpine | head -100Repository: belgattitude/flowblade
Length of output: 4074
Use bundled Corepack and remove npm-install from runtime stage.
Line 11 and Line 93 install Corepack via npm without version pinning, which makes builds non-deterministic. However, the correct fix is to rely on the bundled Corepack in Node.js 24 Alpine images instead of npm-installing it. Simply use
corepack enablewithout thenpm i -g corepackcommand—the bundled version is deterministic by design and matches the Node version exactly. Additionally, remove Corepack entirely from line 93 (runner stage) since the runtime stage doesn't execute package-manager commands.🤖 Prompt for AI Agents