update for publishing and docker setup
Some checks failed
Docker CI / release (push) Has been cancelled

This commit is contained in:
Nicola Zambello 2024-06-15 17:39:17 +03:00
parent 4761f0c25c
commit 5502a26a6c
Signed by: nzambello
GPG key ID: 56E4A92C2C1E50BA
7 changed files with 8420 additions and 5818 deletions

View file

@ -1 +1,2 @@
node_modules node_modules
docs

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
DATABASE_URL="file:/data/sqlite.db?connection_limit=1"
SESSION_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

View file

@ -0,0 +1,70 @@
name: Docker CI
on:
push:
branches:
- main
env:
node-version: 20.x
jobs:
release:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
env:
DOCKER_ORG: nzambello
DOCKER_LATEST: nightly
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
code.nzambello.dev/nzambello/explit
labels: |
org.label-schema.docker.cmd=docker run -d -p 8080:8080 code.nzambello.dev/nzambello/explit:latest
flavor: latest=false
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: code.nzambello.dev
username: ${{ gitea.repository_owner }}
password: ${{ secrets.ACTIONS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ gitea.event_name != 'pull_request' }}
tags: |
code.nzambello.dev/nzambello/explit:latest
labels: $${{ steps.meta.outputs.labels }}
- name: Deploy
uses: darnfish/watchtower-update@v3.2
with:
url: https://watchtower.nzambello.dev/v1/update
api_token: "${{ secrets.WATCHTOWER_API_TOKEN }}"
images: code.nzambello.dev/nzambello/explit

25
.gitignore vendored
View file

@ -1,12 +1,33 @@
node_modules node_modules
.DS_Store .DS_Store
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn-error.log
*.swp
/.cache /.cache
/build /build
/public/build /public/build
/prisma/dev.db /prisma/*.db
/prisma/dev.db-journal /prisma/*.db-journal
.env .env
/app/tailwind.css /app/tailwind.css
.docker
/.cache
/build
/public/build
.env
*.db
*.sqlite

View file

@ -42,7 +42,10 @@ RUN npm run build
# Finally, build the production image with minimal footprint # Finally, build the production image with minimal footprint
FROM base FROM base
ENV NODE_ENV=production ENV DATABASE_URL=file:/data/sqlite.db
ENV PORT="8080"
ENV NODE_ENV="production"
ENV SESSION_SECRET="${SESSION_SECRET:-za1W297qRgKq6PNtm5EXJlOfIto6WTS}"
RUN mkdir /app RUN mkdir /app
WORKDIR /app WORKDIR /app
@ -51,6 +54,14 @@ COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/build /app/build COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public COPY --from=build /app/public /app/public
ADD . . COPY --from=build /app/package.json /app/package.json
COPY --from=build /app/start.sh /app/start.sh
COPY --from=build /app/prisma /app/prisma
CMD ["npm", "run", "start"] RUN npx prisma migrate deploy
RUN chmod +x start.sh
ENTRYPOINT [ "./start.sh" ]
EXPOSE 8080

19
start.sh Normal file
View file

@ -0,0 +1,19 @@
#!/bin/sh
set -ex
# This file is how Fly starts the server (configured in fly.toml). Before starting
# the server though, we need to run any prisma migrations that haven't yet been
# run, which is why this file exists in the first place.
# Learn more: https://community.fly.io/t/sqlite-not-getting-setup-properly/4386
# allocate swap space
# fallocate -l 512M /swapfile
# chmod 0600 /swapfile
# mkswap /swapfile
# echo 10 > /proc/sys/vm/swappiness
# swapon /swapfile
# echo 1 > /proc/sys/vm/overcommit_memory
npx prisma migrate deploy
yarn start

14104
yarn.lock

File diff suppressed because it is too large Load diff