Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7b60192
refactor(oauth): link use url
Marcus-Rise Jul 9, 2024
d0f3224
refactor: db connection
Marcus-Rise Jan 13, 2025
826b846
ci: local db
Marcus-Rise Jan 13, 2025
42268b0
refactor: remove edge route config
Marcus-Rise Jan 13, 2025
238eb11
refactor: remove vercel analytics
Marcus-Rise Jan 13, 2025
0774f17
refactor: remove edge route config
Marcus-Rise Jan 13, 2025
b9e63bf
fix: url href to link
Marcus-Rise Jan 13, 2025
39bdd79
refactor: env
Marcus-Rise Jan 13, 2025
d7487eb
ci: self hosted mod
Marcus-Rise Jan 13, 2025
55196f7
refactor: oauth via vk id
Marcus-Rise Jan 13, 2025
322595c
refactor: demo
Marcus-Rise Jan 13, 2025
c9e3eac
chore: upgrade
Marcus-Rise Jan 13, 2025
7d54e0e
fix: types
Marcus-Rise Jan 13, 2025
6a58a6b
ci: ignore files
Marcus-Rise Jan 13, 2025
37c3b0b
fix: logout redirect
Marcus-Rise Jan 13, 2025
65d92e7
ci: disable telemetry
Marcus-Rise Jan 13, 2025
8ddcdc2
ci: use node 20
Marcus-Rise Jan 13, 2025
90eaba9
fix: redirect url
Marcus-Rise Jan 13, 2025
db285e4
ci: caddy localhost
Marcus-Rise Jan 13, 2025
2fba50d
fix: auth redirect
Marcus-Rise Jan 14, 2025
2848ec5
refactor: reduce db log
Marcus-Rise Jan 14, 2025
8138b35
ci: run migrations
Marcus-Rise Jan 14, 2025
4e7d18c
feat: encoding
Marcus-Rise Jan 14, 2025
33a7ff5
ci: dev config renamed
Marcus-Rise Jan 14, 2025
57c1cb6
ci: production config
Marcus-Rise Jan 14, 2025
310ef0c
ci: freeze postgres version
Marcus-Rise Jan 14, 2025
865c905
ci: build
Marcus-Rise Mar 1, 2025
f764ccc
ci: build
Marcus-Rise Mar 1, 2025
8722273
ci: fix notation
Marcus-Rise Mar 1, 2025
8d59404
ci: reduce push
Marcus-Rise Mar 1, 2025
87ed031
ci: image name
Marcus-Rise Mar 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.dockerignore
.git
.idea
.next
.vercel
node_modules
.storybook
docker-compose.*
Dockerfile
services/caddy/Dockerfile
services/postgres/Dockerfile
16 changes: 9 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
DOMAIN=:80
CANONICAL_BASE_URL=http://localhost:3000

VK_ID_API_URL=
VK_ID_APP_ID=
VK_ID_SERVICE_TOKEN=
VK_ID_REDIRECT_URL=

VK_API_URL=
VK_API_VERSION=
VK_ID_REDIRECT_URL=http://localhost
VK_ID_API_URL=https://id.vk.com
VK_ID_APP_ID='secret to be replaced'
VK_ID_SERVICE_TOKEN='secret to be replaced'

JWT_SECRET='secret to be replaced'

POSTGRES_URL="postgresql://postgres:postgres@localhost:5432/postgres"

# storybook prevent to open new browser window on startup
BROWSER=none

REACT_EDITOR=webstorm
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ci

on:
# schedule:
# - cron: "0 10 * * *"
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:


jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Setup image name
run: |
IMAGE_NAME=$(echo ${{ github.repository }} | tr [:upper:] [:lower:])
echo "IMAGE_NAME=ghcr.io/${IMAGE_NAME}" >> $GITHUB_ENV

-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ env.IMAGE_NAME }}/app
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
80 changes: 80 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# syntax=docker.io/docker/dockerfile:1

FROM node:20-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED=1

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

FROM base AS migrator
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/tsconfig.json ./tsconfig.json
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/src ./src

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV POSTGRES_URL ""

CMD npm run m:m

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD node server.js
71 changes: 71 additions & 0 deletions docker-compose.demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
services:
web:
build:
context: services/caddy
ports:
- "80:80"
env_file:
- .env
- .env.local
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0 || exit 1
interval: 3s
timeout: 5s
retries: 3
depends_on:
- app

app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
env_file:
- .env
- .env.local
environment:
POSTGRES_URL: "postgresql://postgres:postgres@db:5432/postgres"
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0:3000 || exit 1
interval: 3s
timeout: 10s
retries: 3
depends_on:
- db

db-migrator:
build:
context: .
dockerfile: Dockerfile
target: migrator
env_file:
- .env
- .env.local
environment:
POSTGRES_URL: "postgresql://postgres:postgres@db:5432/postgres"
depends_on:
db:
condition: service_healthy

db:
build:
context: services/postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "sh -c 'pg_isready -U postgres -d postgres'" ]
interval: 5s
timeout: 3s
retries: 3

db-browser:
image: adminer
ports:
- "8080:8080"
depends_on:
- db
36 changes: 36 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
db-migrator:
build:
context: .
dockerfile: Dockerfile
target: migrator
env_file:
- .env
- .env.local
environment:
POSTGRES_URL: "postgresql://postgres:postgres@db:5432/postgres"
depends_on:
db:
condition: service_healthy

db:
build:
context: services/postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "sh -c 'pg_isready -U postgres -d postgres'" ]
interval: 5s
timeout: 3s
retries: 3

pgadmin:
image: adminer
ports:
- "8080:8080"
depends_on:
- db
100 changes: 100 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
networks:
private:
public:

volumes:
caddy_data:
caddy_config:
postgres:

services:
web:
build:
context: services/caddy
ports:
- "80:80"
- "443:443"
- "443:443/udp"
env_file:
- .env
- .env.local
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0 || exit 1
interval: 3s
timeout: 5s
retries: 3
restart: always
depends_on:
- app
networks:
- public
volumes:
- caddy_data:/data
- caddy_config:/config
logging:
driver: json-file
options:
max-size: "200k"
max-file: "10"

app:
build:
context: .
dockerfile: Dockerfile
env_file:
- .env
- .env.local
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0:3000 || exit 1
interval: 3s
timeout: 10s
retries: 3
restart: always
depends_on:
- db
networks:
- public
- private
logging:
driver: json-file
options:
max-size: "200k"
max-file: "10"

db-migrator:
build:
context: .
dockerfile: Dockerfile
target: migrator
env_file:
- .env
- .env.local
depends_on:
db:
condition: service_healthy
networks:
- private

db:
build:
context: services/postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
PGDATA: /data/postgres
healthcheck:
test: [ "CMD-SHELL", "sh -c 'pg_isready -U postgres -d postgres'" ]
interval: 5s
timeout: 3s
retries: 3
restart: always
networks:
- private
volumes:
- postgres:/data/postgres
logging:
driver: json-file
options:
max-size: "200k"
max-file: "10"
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const pwaConfig = withPWA({

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
images: {
remotePatterns: [
{
Expand Down
Loading