diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4c6b864 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.gitignore +node_modules +.next +data +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +.env +.env.* \ No newline at end of file diff --git a/.gitea/workflows/release-container.yml b/.gitea/workflows/release-container.yml new file mode 100644 index 0000000..c1e06b5 --- /dev/null +++ b/.gitea/workflows/release-container.yml @@ -0,0 +1,32 @@ +name: release-container + +on: + push: + tags: + - 'v*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set image vars + run: | + echo "IMAGE=git.dou.bet/iamdoubz/drawit" >> $GITHUB_ENV + echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV + + - name: Login to registry + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.dou.bet -u "${{ secrets.REGISTRY_USER }}" --password-stdin + + - name: Build image + run: | + docker build -t $IMAGE:$TAG -t $IMAGE:latest . + + - name: Push image + run: | + docker push $IMAGE:$TAG + docker push $IMAGE:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf91746 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM node:22-bookworm-slim AS deps +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 +COPY package.json package-lock.json* ./ +RUN npm ci + +FROM node:22-bookworm-slim AS builder +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN npm run typecheck && npm run build + +FROM node:22-bookworm-slim AS runner +WORKDIR /app +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=3000 + +COPY package.json package-lock.json* ./ +RUN npm ci --omit=dev && npm cache clean --force + +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/next.config.mjs ./next.config.mjs +COPY --from=builder /app/litestream.yml ./litestream.yml +COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3 + +RUN mkdir -p /app/data +EXPOSE 3000 +CMD ["npm", "run", "start"] \ No newline at end of file