From 83c979c01297021db4c2d5083a38213396206a11 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:23:53 +0200 Subject: [PATCH] docker --- .github/workflows/publish.yml | 34 ++++++++++++++++++++++++++++++++++ Dockerfile | 11 +++++++++++ README.md | 15 +++++++++++++++ svelte.config.js | 2 +- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f205c23 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish to Docker +on: + push: + branches: + - master + +permissions: + packages: write + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/edde746/publish-packages/ephnote + tags: type=sha + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build container + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6e64c6e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:lts-alpine +WORKDIR /app +RUN npm i -g pnpm +COPY package.json pnpm-lock.yaml ./ +RUN pnpm i +RUN pnpm i @sveltejs/adapter-node +COPY . . +RUN sed -i 's/adapter-auto/adapter-node/g' svelte.config.js +RUN pnpm build +RUN pnpm prune --prod +CMD ["node", "build/index.js"] diff --git a/README.md b/README.md index 191145a..b7d1a2c 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,18 @@ For hosting, some viable options are [Vercel](https://vercel.com/) and [Cloudfla ### Environment Variables The only environment variable required is `REDIS_URL`, which should be set to the connection string of your Redis instance. + +## Docker + +Example `docker-compose.yml`: +```yaml +services: + ephnote: + image: ghcr.io/edde746/ephnote:latest + ports: + - 3000:3000 + environment: + - REDIS_URL=redis://redis:6379 + redis: + image: redis:alpine +``` diff --git a/svelte.config.js b/svelte.config.js index ae8957e..4626fa7 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,4 +1,4 @@ -import adapter from "@sveltejs/adapter-auto"; +import adapter from "@sveltejs/adapter-node"; import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; /** @type {import('@sveltejs/kit').Config} */