From 0f974257b4480ee57983e2c9a128d703c1582de8 Mon Sep 17 00:00:00 2001 From: goldengel Date: Sun, 9 Feb 2025 10:25:42 +0100 Subject: [PATCH] first docker example --- Dockerfile | 19 +++++++++---------- README.md | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index fae561b..a2a27a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,13 @@ -FROM node:18.7.0 +FROM node:22.13.1-alpine AS build WORKDIR /app -COPY package.json package.json -COPY yarn.lock yarn.lock +COPY package.json ./ +COPY package-lock.json ./ +RUN npm install +COPY . ./ +RUN npm run build -RUN yarn - -COPY . . - -RUN yarn build - -CMD [ "yarn", "preview", "--host" ] \ No newline at end of file +EXPOSE 80 +FROM nginx:1.19-alpine +COPY --from=build /app/build /usr/share/nginx/html \ No newline at end of file diff --git a/README.md b/README.md index 074ac11..c80c7ab 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,17 @@ npm run build You can preview the production build with `npm run preview`. > To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. + +## Docker + +To run docker type: +```bash +docker build . -t gc-alexandria +docker run --rm --name=gc-alexandria -p 4174:80 gc-alexandria + +``` +Notes: +Dockerized Alexandria starts at port 4174 instead of 4173 in the example. Change the port if you like it. +
Internet page used as guide: https://www.sveltesociety.dev/recipes/publishing-and-deploying/dockerize-a-svelte-app + +