diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..4a289fa --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,38 @@ +name: Build and Deploy + +on: + push: + branches: [master] + +jobs: + build-deploy: + runs-on: ubuntu-latest + container: + image: docker:latest + volumes: + - /opt/coins:/deploy + steps: + - name: Install dependencies + run: apk add --no-cache git nodejs + + - uses: actions/checkout@v4 + + - name: Copy source to deploy directory + run: | + rm -rf /deploy/build + cp -r . /deploy/build + + - name: Create .env file + working-directory: /deploy/build + run: | + echo "PORT=${{ vars.PORT }}" > .env + echo "PHOTOS_DIR=/opt/coins/photos" >> .env + + - name: Build and deploy + working-directory: /deploy/build + run: | + docker compose build + docker compose up -d + + - name: Cleanup + run: rm -rf /deploy/build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a9c39b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM oven/bun:latest AS base +WORKDIR /app + +RUN apt-get update && apt-get install -y imagemagick python3 build-essential && rm -rf /var/lib/apt/lists/* + +FROM base AS deps +COPY package.json bun.lockb ./ +RUN bun install --frozen-lockfile + +FROM deps AS builder +COPY . . +RUN bunx prisma generate +RUN --mount=type=bind,from=photos,source=.,target=/app/public/photos \ + bun run build + +FROM base AS runner +ENV NODE_ENV=production + +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/prisma ./prisma +COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma + +EXPOSE 3000 + +CMD ["bun", "run", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3bb7940 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +name: coins + +services: + app: + build: + context: . + additional_contexts: + - photos=/deploy/photos + ports: + - '${PORT:-3000}:3000' + volumes: + - ${PHOTOS_DIR:-./public/photos}:/app/public/photos + restart: unless-stopped diff --git a/next.config.mjs b/next.config.mjs index 00498ff..0411214 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', reactStrictMode: true, redirects: () => [ {