Browse Source

Added improved docker-compose.yml and docker-stack.yml configs for better local dev and simpler production deployment example (both tested on macOS)

pull/376/head
James Mills 9 months ago
parent
commit
acb5bc126b
Signed by: prologic GPG Key ID: AC4C014F1440EBD6
  1. 51
      Dockerfile.dev
  2. 13
      docker-compose.yml
  3. 21
      docker-stack.yml
  4. 36
      twtxt.yml

51
Dockerfile.dev

@ -0,0 +1,51 @@
# Build
FROM golang:alpine
RUN apk add --no-cache -U build-base git make ffmpeg-dev
RUN mkdir -p /src
WORKDIR /src
# Copy Makefile
COPY Makefile ./
# Copy go.mod and go.sum and install and cache dependencies
COPY go.mod .
COPY go.sum .
# Install deps
RUN make deps
RUN go mod download
# Copy static assets
COPY ./internal/static/css/* ./internal/static/css/
COPY ./internal/static/img/* ./internal/static/img/
COPY ./internal/static/js/* ./internal/static/js/
# Copy pages
COPY ./internal/pages/* ./internal/pages/
# Copy templates
COPY ./internal/templates/* ./internal/templates/
# Copy sources
COPY *.go ./
COPY ./internal/*.go ./internal/
COPY ./internal/auth/*.go ./internal/auth/
COPY ./internal/session/*.go ./internal/session/
COPY ./internal/passwords/*.go ./internal/passwords/
COPY ./internal/webmention/*.go ./internal/webmention/
COPY ./types/*.go ./types/
COPY ./types/retwt/*.go ./types/retwt/
COPY ./cmd/twtd/*.go ./cmd/twtd/
# Build server binary
RUN make server DEBUG=1
VOLUME /src/data
# force cgo resolver
ENV GODEBUG=netdns=cgo
CMD ["./twtd", "-D", "-O", "-R"]

13
docker-compose.yml

@ -3,14 +3,11 @@ version: "3.8"
services:
twtxt:
build: .
image: jointwt/twtxt:latest
command: -d /data -s bitcask:///data/twtxt.db -u http://127.0.0.1:8000
environment:
- OPEN_PROFILES=true
- OPEN_REGISTRATIONS=true
- COOKIE_SECRET=supersecretchange me
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "8000:8000/tcp"
volumes:
- ./data:/data
- ./data:/src/data
- ./internal:/src/internal

21
docker-stack.yml

@ -0,0 +1,21 @@
---
version: "3.8"
services:
twtxt:
image: jointwt/twtxt:latest
command: -d /data -s bitcask:///data/twtxt.db
ports:
- "8000:8000/tcp"
environment:
- BASE_URL=http://127.0.0.1:8000
- OPEN_PROFILES=true
- OPEN_REGISTRATIONS=true
- API_SIGNING_KEY=supersecretchangeme
- COOKIE_SECRET=supersecretchangeme
- MAGICLINK_SECRET=supersecretchangeme
volumes:
- twtxt:/data
volumes:
twtxt:

36
twtxt.yml

@ -1,36 +0,0 @@
---
version: "3.8"
services:
twtxt:
image: prologic/twtxt:latest
command: -d /data -s bitcask:///data/twtxt.db -u https://twtxt.net
environment:
- OPEN_PROFILES=true
- OPEN_REGISTRATIONS=true
- COOKIE_SECRET=supersecretchangeme
volumes:
- twtxt:/data
networks:
- traefik
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- "node.hostname == dm4.mills.io"
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.services.twtxt_twtxt.loadbalancer.server.port=8000"
- "traefik.http.routers.twtxt_twtxt.rule=Host(`twtxt.net`)"
restart_policy:
condition: on-failure
networks:
traefik:
external: true
volumes:
twtxt:
driver: local
Loading…
Cancel
Save