feat(docker): docker support

This commit is contained in:
AlphaNecron 2021-10-04 10:56:00 +07:00
parent b780dfe02c
commit 0ae0a2e08e
5 changed files with 127 additions and 1 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
node_modules/
.next/
uploads/
.git/

41
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: 'docker push'
on:
push:
branches: [ v0 ]
paths:
- 'src/**'
- 'server/**'
- 'prisma/**'
- '.github/**'
workflow_dispatch:
jobs:
push_to_ghcr:
name: push to github packages
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: push
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
repository: AlphaNecron/Void/Void
dockerfile: Dockerfile
tag_with_ref: true
push_to_dockerhub:
name: push to dockerhub
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: push
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: alphaNecron/void
dockerfile: Dockerfile
tag_with_ref: true

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM node:fermium-alpine3.14 AS builder
WORKDIR /build
ENV NEXT_TELEMETRY_DISABLED=1
COPY src ./src
COPY server ./server
COPY scripts ./scripts
COPY prisma ./prisma
COPY package.json yarn.lock next.config.js next-env.d.ts zip-env.d.ts tsconfig.json ./
RUN yarn install
# create a mock config.toml to spoof next build!
RUN echo -e "[core]\nsecret = 'dockersecret'\ndatabase_url = 'postgres://postgres:postgres@postgres/postgres'\n[uploader]\nraw_route = '/r'\ndirectory = './uploads'\n[shortener]\nroute = '/go'" > config.toml
RUN yarn build
FROM node:fermium-alpine3.14 AS runner
WORKDIR /Void
COPY --from=builder /build/node_modules ./node_modules
COPY --from=builder /build/src ./src
COPY --from=builder /build/server ./server
COPY --from=builder /build/scripts ./scripts
COPY --from=builder /build/prisma ./prisma
COPY --from=builder /build/.next ./.next
COPY --from=builder /build/tsconfig.json ./tsconfig.json
COPY --from=builder /build/package.json ./package.json
CMD ["node", "server"]

47
docker-compose.yml Normal file
View File

@ -0,0 +1,47 @@
version: '3'
services:
postgres:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DATABASE=postgres
volumes:
- pg_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5
zipline:
image: ghcr.io/AlphaNecron/Void/Void:v0
ports:
- '3000:3000'
restart: unless-stopped
environment:
- SECURE=false
- SECRET=changethisplease
- HOST=0.0.0.0
- PORT=3000
- DATABASE_URL=postgresql://postgres:postgres@postgres/postgres/
- UPLOADER_RAW_ROUTE=/u
- UPLOADER_LENGTH=6
- UPLOADER_DIRECTORY=./uploads
- UPLOADER_BLACKED=
- SHORTENER_ROUTE=/go
- SHORTENER_LENGTH=6
- BOT_ENABLED=false
- BOT_TOKEN=
- BOT_PREFIX=&
- BOT_ADMINS=
- BOT_LOG_CHANNEL=
- BOT_HOSTNAME=localhost
volumes:
- '$PWD/uploads:/Void/uploads'
- '$PWD/public:/Void/public'
depends_on:
- 'postgres'
volumes:
pg_data:

View File

@ -1,6 +1,6 @@
{
"name": "void",
"version": "0.2.3",
"version": "0.3.0",
"private": true,
"engines": {
"node": ">=14"
@ -136,6 +136,7 @@
"prisma",
"scripts",
"server",
"docker",
"pages",
"config",
"api",