Skip to content

Instantly share code, notes, and snippets.

@Maxiviper117
Created April 9, 2023 09:42
Show Gist options
  • Save Maxiviper117/6410962a4e0b16538b7fb6ecd567afbc to your computer and use it in GitHub Desktop.
Save Maxiviper117/6410962a4e0b16538b7fb6ecd567afbc to your computer and use it in GitHub Desktop.
Example `dockerfile` for a Sveltekit Project
# ---- Base Node ----
FROM node:19-alpine AS base
WORKDIR /app
COPY package*.json ./
# ---- Dependencies ----
FROM base AS dependencies
RUN npm ci
# ---- Build ----
FROM dependencies AS build
COPY . .
RUN npm run build
# ---- Production ----
FROM node:19-alpine AS production
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY --from=build /app/build ./build
COPY --from=build /app/package*.json ./
# Expose the port the app will run on
EXPOSE 3000
# Start the application
# added "start": "node ./build", to package.json "scripts" section
CMD ["npm", "start"]
@Maxiviper117
Copy link
Author

Maxiviper117 commented Apr 9, 2023

Ensure to install this dependency:

npm install @sveltejs/adapter-node --save-dev

Modify svelte.config.js

// import adapter from '@sveltejs/adapter-auto'; <-- Remove
import adapter from '@sveltejs/adapter-node'; // <-- Add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment