Skip to content

Commit 567af6a

Browse files
committed
feat: Add Docker and Node adapter for deployment
- Configure dynamic adapter selection - Switch to $env/dynamic/public for environment variables - Move husky to dependencies
1 parent 7a6bbe3 commit 567af6a

File tree

8 files changed

+170
-17
lines changed

8 files changed

+170
-17
lines changed

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Dockerfile
2+
compose.yml
3+
.dockerignore
4+
5+
.git
6+
.gitignore
7+
.gitattributes
8+
9+
10+
.npmrc
11+
.prettierrc
12+
.eslintrc.cjs
13+
.graphqlrc
14+
.editorconfig
15+
.svelte-kit
16+
.vscode
17+
node_modules
18+
build
19+
package
20+
**/.env
21+
22+
README.md

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG NODE_VERSION=22
2+
3+
4+
FROM node:${NODE_VERSION}-slim AS base
5+
6+
ENV SVELTEKIT_ADAPTER=nodejs
7+
ENV PNPM_HOME="/pnpm"
8+
ENV PATH="$PNPM_HOME:$PATH"
9+
10+
RUN corepack enable
11+
COPY . /app
12+
WORKDIR /app
13+
14+
FROM base AS deps-prod
15+
RUN pnpm install --frozen-lockfile --prod
16+
17+
FROM base AS build
18+
RUN pnpm install --frozen-lockfile
19+
RUN pnpm run build
20+
21+
FROM base
22+
COPY --from=deps-prod /app/node_modules /app/node_modules
23+
COPY --from=build /app/build /app/build
24+
EXPOSE 3000
25+
CMD [ "node", "build" ]

compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
explorer:
3+
build: .
4+
env_file: .env
5+
ports:
6+
- '3000:3000'

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@iconify/tailwind4": "^1.0.6",
4040
"@openfoodfacts/openfoodfacts-nodejs": "2.0.0-alpha.19",
4141
"@sinnwerkstatt/sveltekit-matomo": "github:VaiTon/sveltekit-matomo",
42+
"@sveltejs/adapter-node": "^5.3.3",
4243
"@sveltejs/adapter-vercel": "^5.10.3",
4344
"@sveltejs/kit": "^2.44.0",
4445
"@sveltejs/vite-plugin-svelte": "^6.2.1",
@@ -59,7 +60,6 @@
5960
"fuse.js": "^7.1.0",
6061
"globals": "^16.4.0",
6162
"html5-qrcode": "^2.3.8",
62-
"husky": "^9.1.7",
6363
"iso-639-1": "^3.1.5",
6464
"jsbarcode": "^3.12.1",
6565
"leaflet": "^1.9.4",
@@ -105,6 +105,7 @@
105105
"dependencies": {
106106
"@openfoodfacts/openfoodfacts-webcomponents": "^1.14.2",
107107
"@sentry/sveltekit": "^10.17.0",
108-
"@webcomponents/webcomponentsjs": "^2.8.0"
108+
"@webcomponents/webcomponentsjs": "^2.8.0",
109+
"husky": "^9.1.7"
109110
}
110111
}

pnpm-lock.yaml

Lines changed: 96 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/const.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import {
1+
import { env as publicEnv } from '$env/dynamic/public';
2+
3+
const {
4+
PUBLIC_ROBOTOFF_URL,
5+
PUBLIC_IMAGES_URL,
6+
PUBLIC_NUTRIPATROL_URL,
27
PUBLIC_AUTH_BASE_URL,
38
PUBLIC_AUTH_PKCE_ID,
4-
PUBLIC_IMAGES_URL,
5-
PUBLIC_KEYCLOAK_REALM,
6-
PUBLIC_ROBOTOFF_URL,
7-
PUBLIC_NUTRIPATROL_URL
8-
} from '$env/static/public';
9+
PUBLIC_KEYCLOAK_REALM
10+
} = publicEnv;
911

1012
export {
1113
PUBLIC_ROBOTOFF_URL as ROBOTOFF_URL,

src/routes/settings/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import * as publicEnv from '$env/static/public';
2+
import * as publicEnv from '$env/dynamic/public';
33
44
import { preferences } from '$lib/settings';
55
import { createFolksonomyApi, updateFolksonomyAuthToken } from '$lib/api/folksonomy';

svelte.config.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import adapter from '@sveltejs/adapter-vercel';
1+
import vercelAdapter from '@sveltejs/adapter-vercel';
2+
import nodejsAdapter from '@sveltejs/adapter-node';
23
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
34

5+
function runningOnVercel() {
6+
return 'VERCEL' in process.env;
7+
}
8+
9+
const adapter = runningOnVercel() ? vercelAdapter() : nodejsAdapter();
10+
411
/** @type {import('@sveltejs/kit').Config} */
512
const config = {
613
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
714
// for more information about preprocessors
815
preprocess: vitePreprocess(),
916

1017
kit: {
11-
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12-
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
13-
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
14-
adapter: adapter(),
18+
adapter: adapter,
1519

1620
csp: {
1721
directives: {

0 commit comments

Comments
 (0)