diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a2b80a6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_moduels +ssb-go-room-secrets +ssb-go-room-secrets/**/* +.git diff --git a/.env_example b/.env_example new file mode 100644 index 0000000..d0726d7 --- /dev/null +++ b/.env_example @@ -0,0 +1,4 @@ +HTTPS_DOMAIN=yourhttpsdomainhere +ALIASES_AS_SUBDOMAINS=true +# uncomment variable if you want to store data in a custom directory (required for default docker-compose setup) +# REPO=/ssb-go-room-secrets diff --git a/.gitignore b/.gitignore index 2766f09..6475f8b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ node_modules # goreleaser output dist/ + +# secrets and config +ssb-go-room-secrets/ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffaf68b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.16-alpine + +RUN apk add --no-cache \ + build-base \ + git \ + sqlite \ + sqlite-dev + +RUN mkdir /app +WORKDIR /app +COPY . /app + +RUN cd /app/cmd/server && go build && \ + cd /app/cmd/insert-user && go build + +EXPOSE 8008 +EXPOSE 3000 + +RUN apk del \ + build-base \ + git + +CMD ./start.sh diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..be9b351 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' +services: + room: + build: . + command: 'sh start.sh' + env_file: .env + ports: + - "3000:3000" # Proxypass this port through NGINX or Apache as your HTTP landing & dashboard page + - "0.0.0.0:8008:8008" # This is the port SSB clients connect to + volumes: + - ./ssb-go-room-secrets:/ssb-go-room-secrets diff --git a/docs/deployment.md b/docs/deployment.md index 8aff5a8..784e3ec 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -21,6 +21,46 @@ After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special att * You should now have a working go-ssb-room binary! Read the HTTP Hosting section below and admin user sections below, for more instructions on the last mile. +# Docker & Docker-compose + +This project includes a docker-compose.yml file as well as a Docker file. Using +it should be fairly straight forward. + +Start off by making a copy of `.env_example` called `.env` and insert your +website domain there. With that done execute + +``` +docker-compose build room +``` + +Followed by + +``` +docker-compose up +``` + +Your database, secrets and other things will be synchronized to a folder in your +project called "docker-secrets". + +After starting your server for the first time you need to enter your running +server to insert your first user (your docker-compose up should be active). +You can do this by: + +``` +docker-compose exec room sh +``` + +Then inside the virtual machine: + +``` +/app/cmd/insert-user/insert-user -repo /ssb-go-room-secrets @your-own-ssb-public-key +``` + +Fill in your password and then exit your instance by typing `exit`. + +You should setup Nginx or HTTPS load-balancing outside the docker-compose +instance. + # HTTP Hosting We currently assume a standard HTTPS server in front of go-ssb-room to facilitate TLS @@ -68,4 +108,4 @@ example (with custom repo location, only needed if you setup your with a custom ./insert-user -repo "/ssb-go-room-secrets" "@Bp5Z5TQKv6E/Y+QZn/3LiDWMPi63EP8MHsXZ4tiIb2w=.ed25519" ``` -You can now login in the web-front-end using these credentials \ No newline at end of file +You can now login in the web-front-end using these credentials diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..833f546 --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +[[ -f ".env" ]] && source .env +./cmd/server/server -https-domain "${HTTPS_DOMAIN}" -repo "${REPO:-~/.ssb-go-room-secrets}" -aliases-as-subdomains "${ALIASES_AS_SUBDOMAINS}"