mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
refactorin docker files
This commit is contained in:
parent
803a217122
commit
d2f08d3412
9 changed files with 24 additions and 46 deletions
BIN
docker/db.sqlite
BIN
docker/db.sqlite
Binary file not shown.
|
@ -1,4 +1,3 @@
|
|||
FROM node:latest
|
||||
EXPOSE 13120
|
||||
WORKDIR /
|
||||
RUN yarn global add gancio
|
|
@ -18,6 +18,7 @@ services:
|
|||
build: .
|
||||
image: node:latest
|
||||
container_name: gancio
|
||||
restart: always
|
||||
command: gancio start --docker --db=postgresql
|
||||
volumes:
|
||||
- ./config.json:/opt/gancio/config.json
|
||||
|
@ -25,7 +26,4 @@ services:
|
|||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- 13120:13120
|
||||
volumes:
|
||||
db:
|
||||
gancio:
|
||||
- "localhost:13120:13120"
|
|
@ -3,15 +3,15 @@ version: '3'
|
|||
services:
|
||||
gancio:
|
||||
build: .
|
||||
restart: always
|
||||
image: node:latest
|
||||
container_name: gancio
|
||||
command: gancio start --docker --db=sqlite
|
||||
environment:
|
||||
- DEBUG
|
||||
volumes:
|
||||
- ./db.sqlite:/opt/gancio/db.sqlite
|
||||
- ./config.json:/opt/gancio/config.json
|
||||
- ./uploads:/opt/gancio/uploads
|
||||
ports:
|
||||
- 13120:13120
|
||||
volumes:
|
||||
db:
|
||||
gancio:
|
||||
- "127.0.0.1:13120:13120"
|
|
@ -12,7 +12,7 @@ parent: Install
|
|||
|
||||
## Initial setup
|
||||
**You do not need to clone the full repo as we distribute gancio via npm.**
|
||||
A [Dockerfile](https://framagit.org/les/gancio/raw/docker/docker/Dockerfile) and a docker-compose.yml are the only files needed.
|
||||
A Dockerfile and a docker-compose.yml are the only files needed.
|
||||
|
||||
- __Create a directory where everything related to gancio is stored (db, images, config)__
|
||||
```bash
|
||||
|
@ -25,9 +25,8 @@ cd /opt/gancio
|
|||
<div class='code-example bg-grey-lt-100' markdown="1">
|
||||
1. **Download docker-compose.yml and Dockerfile**
|
||||
```bash
|
||||
wget https://framagit.org/les/gancio/raw/master/docker/Dockerfile
|
||||
wget https://framagit.org/les/gancio/raw/master/docker/docker-compose.sqlite.yml \
|
||||
-O docker-compose.yml
|
||||
wget https://gancio.org/docker/Dockerfile
|
||||
wget https://gancio.org/docker/sqlite/docker-compose.yml
|
||||
```
|
||||
|
||||
1. Create an empty db and config (**this is needed**)
|
||||
|
@ -38,6 +37,7 @@ mkdir user_locale
|
|||
|
||||
1. Build docker image and launch interactive setup in one step
|
||||
```
|
||||
docker-compose build
|
||||
docker-compose run --rm gancio gancio setup --docker --db=sqlite
|
||||
```
|
||||
</div>
|
||||
|
@ -47,9 +47,8 @@ docker-compose run --rm gancio gancio setup --docker --db=sqlite
|
|||
|
||||
1. **Download docker-compose.yml and Dockerfile**
|
||||
```bash
|
||||
wget https://framagit.org/les/gancio/raw/master/docker/Dockerfile
|
||||
wget https://framagit.org/les/gancio/raw/master/docker/docker-compose.postgresql.yml \
|
||||
-O docker.compose.yml
|
||||
wget https://gancio.org/docker/Dockerfile
|
||||
wget https://gancio.org/docker/sqlite/docker-compose.yml
|
||||
```
|
||||
|
||||
1. Create an empty configuration (**this is needed**)
|
||||
|
@ -60,6 +59,7 @@ mkdir user_locale
|
|||
|
||||
1. Build docker image and launch interactive setup in one step
|
||||
```
|
||||
docker-compose build
|
||||
docker-compose run --rm gancio gancio setup --docker --db=postgresql
|
||||
```
|
||||
</div>
|
||||
|
|
|
@ -11,6 +11,7 @@ const settingsController = require('./settings')
|
|||
const federation = require('../../federation/helpers')
|
||||
const util = require('util')
|
||||
const generateKeyPair = util.promisify(crypto.generateKeyPair)
|
||||
const debug = require('debug')('user:controller')
|
||||
|
||||
const userController = {
|
||||
async login (req, res) {
|
||||
|
@ -237,22 +238,6 @@ const userController = {
|
|||
|
||||
if (!req.body.password) { delete req.body.password }
|
||||
|
||||
// generate an rsa key in case not present
|
||||
if (!user.rsa) {
|
||||
const rsa = await generateKeyPair('rsa', {
|
||||
modulusLength: 4096,
|
||||
publicKeyEncoding: {
|
||||
type: 'spki',
|
||||
format: 'pem'
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
format: 'pem'
|
||||
}
|
||||
})
|
||||
req.body.rsa = rsa
|
||||
}
|
||||
|
||||
await user.update(req.body)
|
||||
|
||||
if (!user.is_active && req.body.is_active && user.recover_code) {
|
||||
|
|
|
@ -65,7 +65,7 @@ async function setupQuestionnaire(is_docker, db) {
|
|||
message: 'sqlite db path',
|
||||
default: is_docker ? '/opt/gancio/db.sqlite' : './db.sqlite',
|
||||
filter: p => path.resolve(cwd, p),
|
||||
when: answers => (db && db==='sqlite') || (answers.db && answers.db.dialect === 'sqlite'),
|
||||
when: answers => ((db && db==='sqlite') || (answers.db && answers.db.dialect === 'sqlite')) && !is_docker,
|
||||
validate: db_path => db_path.length>0 && fs.existsSync(path.dirname(db_path))
|
||||
})
|
||||
|
||||
|
@ -73,7 +73,7 @@ async function setupQuestionnaire(is_docker, db) {
|
|||
name: 'db.host',
|
||||
message: 'Postgres host',
|
||||
default: is_docker ? 'db' : 'localhost',
|
||||
when: answers => (db && db==='postgresql') || (answers.db && answers.db.dialect === 'postgres'),
|
||||
when: answers => ((db && db==='postgresql') || (answers.db && answers.db.dialect === 'postgres')) && !is_docker,
|
||||
validate: notEmpty
|
||||
})
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ const httpSignature = require('http-signature')
|
|||
const debug = require('debug')('federation:helpers')
|
||||
const { user: User, fed_users: FedUsers } = require('../api/models')
|
||||
const url = require('url')
|
||||
const settings = require('../api/controller/settings')
|
||||
const settingsController = require('../api/controller/settings')
|
||||
|
||||
const Helpers = {
|
||||
|
||||
|
@ -53,12 +53,11 @@ const Helpers = {
|
|||
},
|
||||
|
||||
async sendEvent (event, user) {
|
||||
if (!settings.settings.enable_federation) {
|
||||
if (!settingsController.settings.enable_federation) {
|
||||
debug('event not send, federation disabled')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// event is sent by user that published it and by the admin instance
|
||||
// collect followers from admin and user
|
||||
const instanceAdmin = await User.findOne({ where: { email: config.admin_email }, include: { model: FedUsers, as: 'followers' } })
|
||||
|
@ -128,15 +127,6 @@ const Helpers = {
|
|||
|
||||
},
|
||||
|
||||
// DO NOT USE THIS! (why is this needed btw?)
|
||||
// async getFederatedUser (address) {
|
||||
// address = address.trim()
|
||||
// const [ username, host ] = address.split('@')
|
||||
// const url = `https://${host}/.well-known/webfinger?resource=acct:${username}@${host}`
|
||||
// return Helpers.getActor(url)
|
||||
// },
|
||||
|
||||
// TODO: cache
|
||||
async getActor (url, force = false) {
|
||||
let fedi_user
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ const cors = require('cors')
|
|||
const Follows = require('./follows')
|
||||
const Users = require('./users')
|
||||
const { event: Event, user: User, tag: Tag, place: Place } = require('../api/models')
|
||||
const settingsController = require('../api/controller/settings')
|
||||
const Comments = require('./comments')
|
||||
const Helpers = require('./helpers')
|
||||
const Ego = require('./ego')
|
||||
|
@ -14,6 +15,11 @@ const debug = require('debug')('federation')
|
|||
* ref: https://www.w3.org/TR/activitypub/#Overview
|
||||
*/
|
||||
|
||||
router.use((req, res, next) => {
|
||||
if(settingsController.settings.enable_federation) next()
|
||||
debug('Federation disabled!')
|
||||
return res.status(401).send('Federation disabled')
|
||||
})
|
||||
|
||||
router.use(cors())
|
||||
router.use(express.json({ type: ['application/json', 'application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'] }))
|
||||
|
|
Loading…
Reference in a new issue