From 927ec5d8b365f7630860ad3213fa37ce075f49a2 Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Mon, 1 Nov 2021 18:05:14 -0500 Subject: [PATCH] add docker deployment --- .dockerignore | 7 +++++++ .env.defaults | 2 ++ .gitignore | 1 + Dockerfile | 23 +++++++++++++++++++++++ README.md | 27 ++++++++++++++++++++------- docker-compose.yml | 37 +++++++++++++++++++++++++++++++++++++ index.js | 6 ++---- package-lock.json | 14 ++++++++++++++ package.json | 1 + web/package.json | 10 +++++----- 10 files changed, 112 insertions(+), 16 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.defaults create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..17791cb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +web/node_modules +npm-debug.log +certs +.vscode +web/dist +.env diff --git a/.env.defaults b/.env.defaults new file mode 100644 index 0000000..d0db5b7 --- /dev/null +++ b/.env.defaults @@ -0,0 +1,2 @@ +DB_NAME=guppe +NODE_ENV=production diff --git a/.gitignore b/.gitignore index be3c4fc..3e87252 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ certs/ .vscode dump/ logs/ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9477d4e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM node:16 + +# Web clinet installs +WORKDIR /usr/src/guppe/web +COPY ./web/package*.json ./ +RUN npm ci + +# server installs +WORKDIR /usr/src/guppe +COPY package*.json ./ +RUN npm ci + +# source +COPY . . + +# web client build +WORKDIR /usr/src/guppe/web +RUN npm run build + +# entry +WORKDIR /usr/src/guppe +EXPOSE 443 80 +CMD [ "node", "index.js" ] diff --git a/README.md b/README.md index f0abf36..d123990 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,34 @@ -# Current state of guppe - -Guppe is a tech demo. It is missing a lot of features, and I am in the process of rewriting it's core code from scratch in the fully-implemented, [modular ActivityPub library activitypub-express](https://github.com/immers-space/activitypub-express). I'll try to keep up with major bugfixes, but I won't be adding any features to guppe until i finish apex and can port guppe over to the new engine. - # Gup.pe Social groups for the fediverse - making it easy to connect and meet new people based on shared interests without the manipulation of your attention to maximize ad revenue nor the walled garden lock-in of capitalist social media. This server-2-server ActivityPub implementation adds decentralized, federaded "groups" support across all ActivityPub compliant social media networks. Users join groups by following group-type actors on Guppe servers and contribute to groups by mentioning those same actors in a post. Guppe group actors will automatically forward posts they receive to all group members so that everyone in the group sees any post made to the group. Guppe group actors' profiles (e.g. outboxes) also serve as a group discussion history. +Creation of new groups is automatic, users simply search for or mention a new group and it will be created. + ## Tech stack -MEVN: MongoDB, ExpressJS, Vue, NodeJS +Mostly powered by [activitypub-express](https://github.com/immers-space/activitypub-express) +from [Immers Space](https://web.immers.space). +The gup.pe server app, `index.js` is < 200 lines of code, +just adding the auto-create actor, auto-accept follow, and auto-boost from inbox behaviors +to the base apex setup. + +There's also an HTML front-end using Vue (`/web`) to display popular groups and provide +fallback user profile discovery. ## Installation -Instructions coming soon. +`Dockerfile` and `docker-compose.yml` are provided for easy install + +``` +git clone https://github.com/wmurphyrd/guppe.git +cd guppe +cp .env.defaults .env +echo DOMAIN=yourdomain.com >> .env +docker-compose up -d +``` ## License -Copyright (c) 2019 William Murphy. Licensed under the AGPL-3 +Copyright (c) 2021 William Murphy. Licensed under the AGPL-3 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..40572bd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: "3.8" + +services: + guppe: + build: . + restart: unless-stopped + ports: + - 443:443 + - 80:80 + env_file: '.env' + environment: + DB_URL: 'mongodb://mongodb:27017' + PORT_HTTPS: 443 + depends_on: + - mongodb + volumes: + - certs:/root/.small-tech.org/auto-encrypt + # localdev certs + - ./certs:/usr/src/guppe/certs + logging: + driver: local + options: + max-size: '10m' + + mongodb: + image: mongo:4.2 + restart: unless-stopped + volumes: + - mongo-data:/data/db + logging: + driver: local + options: + max-size: '10m' + +volumes: + mongo-data: + certs: diff --git a/index.js b/index.js index 359556b..b6a811e 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +require('dotenv').config() const path = require('path') const express = require('express') const MongoClient = require('mongodb').MongoClient @@ -8,7 +9,7 @@ const history = require('connect-history-api-fallback') const { onShutdown } = require('node-graceful-shutdown') const ActivitypubExpress = require('activitypub-express') -const { DOMAIN, KEY_PATH, CERT_PATH, CA_PATH, PORT, PORT_HTTPS, DB_URL, DB_NAME } = require('./config.json') +const { DOMAIN, KEY_PATH, CERT_PATH, CA_PATH, PORT_HTTPS, DB_URL, DB_NAME } = process.env const app = express() @@ -50,9 +51,6 @@ const apex = ActivitypubExpress({ routes }) -app.set('domain', DOMAIN) -app.set('port', process.env.PORT || PORT) -app.set('port-https', process.env.PORT_HTTPS || PORT_HTTPS) app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status Accepts ":req[accept]" ":referrer" ":user-agent"')) app.use(express.json({ type: apex.consts.jsonldTypes }), apex) diff --git a/package-lock.json b/package-lock.json index c63bcc7..7b5f8a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "activitypub-express": "^2.2.1", "connect-history-api-fallback": "^1.6.0", "cors": "^2.8.4", + "dotenv": "^10.0.0", "express": "^4.16.3", "express-basic-auth": "^1.1.5", "http-signature": "github:wmurphyrd/node-http-signature#9c02eeb", @@ -1301,6 +1302,14 @@ "node": ">=4" } }, + "node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", @@ -7517,6 +7526,11 @@ "is-obj": "^1.0.0" } }, + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", diff --git a/package.json b/package.json index e2f468d..f5d0b4d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "activitypub-express": "^2.2.1", "connect-history-api-fallback": "^1.6.0", "cors": "^2.8.4", + "dotenv": "^10.0.0", "express": "^4.16.3", "express-basic-auth": "^1.1.5", "http-signature": "github:wmurphyrd/node-http-signature#9c02eeb", diff --git a/web/package.json b/web/package.json index 6828382..2f1e1ff 100644 --- a/web/package.json +++ b/web/package.json @@ -10,22 +10,22 @@ "dev": "vue-cli-service build --watch --mode development" }, "dependencies": { + "@vue/cli-plugin-babel": "^3.11.0", + "@vue/cli-service": "^3.11.0", "core-js": "^2.6.5", "vue": "^2.6.10", - "vue-router": "^3.0.3" + "vue-router": "^3.0.3", + "vue-template-compiler": "^2.6.10" }, "devDependencies": { - "@vue/cli-plugin-babel": "^3.11.0", "@vue/cli-plugin-eslint": "^3.11.0", "@vue/cli-plugin-unit-mocha": "^3.11.0", - "@vue/cli-service": "^3.11.0", "@vue/eslint-config-standard": "^4.0.0", "@vue/test-utils": "1.0.0-beta.29", "babel-eslint": "^10.0.1", "chai": "^4.1.2", "eslint": "^5.16.0", - "eslint-plugin-vue": "^5.0.0", - "vue-template-compiler": "^2.6.10" + "eslint-plugin-vue": "^5.0.0" }, "eslintConfig": { "root": true,