Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
feat(docker): docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaNecron committed Oct 4, 2021
1 parent b780dfe commit 0ae0a2e
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .dockerignore
@@ -0,0 +1,4 @@
node_modules/
.next/
uploads/
.git/
41 changes: 41 additions & 0 deletions .github/workflows/docker.yml
@@ -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 changes: 33 additions & 0 deletions Dockerfile
@@ -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 changes: 47 additions & 0 deletions docker-compose.yml
@@ -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:
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "void",
"version": "0.2.3",
"version": "0.3.0",
"private": true,
"engines": {
"node": ">=14"
Expand Down Expand Up @@ -136,6 +136,7 @@
"prisma",
"scripts",
"server",
"docker",
"pages",
"config",
"api",
Expand Down

0 comments on commit 0ae0a2e

Please sign in to comment.