Skip to content

Commit

Permalink
Merge pull request #48 from k0staa/master
Browse files Browse the repository at this point in the history
Moving the server-docker repository to the server repository and enabling image building from the current version of the application code
  • Loading branch information
xthursdayx authored Sep 18, 2021
2 parents 7884354 + 7a73d96 commit 2b3b2ae
Show file tree
Hide file tree
Showing 14 changed files with 447 additions and 74 deletions.
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DS_Store

# ignore .git and .cache folders
.git*
.cache

# ignore all markdown files
*.md

# Ignore database files
*.sqlite

# ignore other directories
docker
!docker/entrypoint.sh
!docker/.env
node_modules



8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOST=127.0.0.1
PORT=3333
NODE_ENV=development

APP_NAME=AdonisJs
APP_NAME=Ferdi-server
APP_URL=http://${HOST}:${PORT}
EXTERNAL_DOMAIN=ferdi.domain.tld

Expand All @@ -17,10 +17,12 @@ DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=
DB_DATABASE=adonis

DB_DATABASE=ferdi
DB_SSL=false

PUID=1000
PGID=1000

HASH_DRIVER=bcrypt

IS_CREATION_ENABLED=true
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ node_modules
tmp

# Environment variables, never commit this file
.env
# .env

# The development sqlite file
data*/development.sqlite
data*/adonis.sqlite
*.sqlite

# Uploaded recipes
recipes/

.DS_Store
public/terms.html
public/privacy.html

resources/announcements/*.json
!resources/announcements/version.json
Expand Down
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:lts-alpine as build

WORKDIR /server-build

RUN ["apk", "add", "--no-cache", "python", "make", "gcc", "g++", "libc-dev", "sqlite-dev"]

COPY . /server-build

RUN ["npm", "ci", "--production", "--build-from-source", "--sqlite=/usr/local"]

FROM node:lts-alpine

WORKDIR /app
LABEL maintainer="xthursdayx"

ENV HOST=0.0.0.0 PORT=3333 DATA_DIR="/data"

RUN ["apk", "add", "--no-cache", "sqlite-libs", "curl", "su-exec"]

COPY --from=build /server-build /app
RUN ["npm", "i", "-g", "@adonisjs/cli"]

HEALTHCHECK --interval=5m --timeout=3s CMD curl -sSf http://localhost:${PORT}/health

COPY docker/entrypoint.sh /entrypoint.sh
COPY docker/.env /app/.env
CMD ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 vantezzen
Copyright (c) 2019 Ferdi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
93 changes: 29 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<img src="./logo.png" alt="" width="300"/>
</p>

# ferdi-server
# Ferdi-server
Official Server software for the [Ferdi Messaging Browser](https://getferdi.com)

- [ferdi-server](#ferdi-server)
- [Ferdi-server](#ferdi-server)
- [Why use a custom Ferdi server?](#why-use-a-custom-ferdi-server)
- [Features](#features)
- [Setup](#setup)
Expand All @@ -16,37 +16,39 @@ Official Server software for the [Ferdi Messaging Browser](https://getferdi.com)
- [Transferring user data](#transferring-user-data)
- [Creating and using custom recipes](#creating-and-using-custom-recipes)
- [Listing custom recipes](#listing-custom-recipes)
- [Contributing to ferdi-server's development](#contributing-to-ferdi-servers-development)
- [Contributing to Ferdi-server's development](#contributing-to-ferdi-servers-development)
- [License](#license)

## Why use a custom Ferdi server?
## Why use a custom Ferdi-server?
A custom server allows you to manage the data of all registered users yourself and add your own recipes to the repository.

If you are not interested in doing this you can use our official instance of Ferdi server at <https://api.getferdi.com>.
If you are not interested in doing this you can use our official instance of Ferdi-server at <https://api.getferdi.com>.

## Features
- [x] User registration and login
- [x] Service creation, download, listing and removing
- [x] Workspace support
- [x] Functioning service store
- [x] User dashboard
- [x] Export/import data to other ferdi-servers
- [x] Export/import data to other Ferdi-servers
- [ ] Password recovery
- [ ] Recipe update

## Setup
### with Docker
The easiest way to set up Ferdi server on your server is with Docker.
The easiest way to set up Ferdi-server on your server is with Docker.

The Docker image can be run as is, with the default sqlite database or you can modifying your ENV variables to use an external database (e.g. MySQL, MariaDB, Postgres, etc).
After setting up the docker container we recommend you to set up an NGINX reverse proxy to access ferdi-server outside of your home network and protect it with an SSL certificate.
The Docker image can be run as is, with the default SQLite database or you can modify your ENV variables to use an external database (e.g. MySQL, MariaDB, Postgres, etc).
After setting up the docker container we recommend you set up an NGINX reverse proxy to access Ferdi-server outside of your home network and protect it with an SSL certificate.

**Warning**, please note that the use of the previous `config.txt` is now deprecated and a number of environmental variables have changed, specifically the default database name and location, the internal container port, and an additional `DATA_DIR` variable has been added. Make sure to pass the correct environmental variables to your container at runtime. If you are an existing Ferdi-server user, please see [the Ferdi docker documentation](./docker/README.md) for more information about migrating to the new image.

1. Pull the Docker image

```sh
docker pull getferdi/ferdi-server
```
2. Create a new Docker container with your desired configuration
2. Create a *new* Docker container with your desired configuration **Existing users please seee the warning above.**

```sh
docker create \
Expand All @@ -71,56 +73,19 @@ After setting up the docker container we recommend you to set up an NGINX revers
-e IS_DASHBOARD_ENABLED=true \
-e IS_REGISTRATION_ENABLED=true \
-e CONNECT_WITH_FRANZ=true \
-p <port>:80 \
-v <path to data>:/config \
-v <path to database>:/app/database \
-e DATA_DIR=data \
-p <port>:3333 \
-v <path to data>:/data \
-v <path to recipes>:/app/recipes \
--restart unless-stopped \
getferdi/ferdi-server
```

Alternatively, you can also use docker-compose v2 schemas

```sh
---
version: "2"
services:
ferdi-server:
image: getferdi/ferdi-server
container_name: ferdi-server
environment:
- NODE_ENV=development
- EXTERNAL_DOMAIN=<ferdi-serverdomain>
- DB_CONNECTION=<database>
- DB_HOST=<yourdbhost>
- DB_PORT=<yourdbPORT>
- DB_USER=<yourdbuser>
- DB_PASSWORD=<yourdbpass>
- DB_DATABASE=<yourdbdatabase>
- DB_SSL=true/false
- MAIL_CONNECTION=<mailsender>
- SMPT_HOST=<smtpmailserver>
- SMTP_PORT=<smtpport>
- MAIL_SSL=true/false
- MAIL_USERNAME=<yourmailusername>
- MAIL_PASSWORD=<yourmailpassword>
- MAIL_SENDER=<sendemailaddress>
- IS_CREATION_ENABLED=true/false
- IS_DASHBOARD_ENABLED=true/false
- IS_REGISTRATION_ENABLED=true/false
- CONNECT_WITH_FRANZ=true/false
volumes:
- <path to data>:/config
- <path to database>:/app/database
- <path to recipes>:/app/recipes
ports:
- <port>:80
restart: unless-stopped
```
Alternatively, you can also use docker-compose v2 schema. An example can be found [in the docker folder](./docker/docker-compose.yml).

3. Optionally, you can now [set up Nginx as a reverse proxy](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server).
3. Optionally, you can [set up Nginx as a reverse proxy](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server).

For more information on configuring the Docker image, visit the Docker image repository at <https://github.com/getferdi/server-docker>.
For more information on configuring the Docker image, please read [the Ferdi docker documentation](./docker/README.md).

### Manual setup

Expand All @@ -143,46 +108,46 @@ For more information on configuring the Docker image, visit the Docker image rep

## Configuration

franz-server's configuration is saved inside the `.env` file. Besides AdonisJS's settings, ferdi-server has the following custom settings:
franz-server's configuration is saved inside an `.env` file. Besides AdonisJS's settings, Ferdi-server has the following custom settings:
- `IS_CREATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the [creation of custom recipes](#creating-and-using-custom-recipes)
- `IS_REGISTRATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the creation of new user accounts
- `IS_DASHBOARD_ENABLED` (`true` or `false`, default: `true`): Whether to enable the user dashboard
- `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, ferdi-server can:
- `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, Ferdi-server can:
- Show the full Franz recipe library instead of only custom recipes
- Import Franz accounts

## Importing your Franz account

ferdi-server allows you to import your full Franz account, including all its settings.
Ferdi-server allows you to import your full Franz account, including all its settings.

To import your Franz account, open `http://[YOUR FERDI-SERVER]/import` in your browser and login using your Franz account details. ferdi-server will create a new user with the same credentials and copy your Franz settings, services and workspaces.
To import your Franz account, open `http://[YOUR FERDI-SERVER]/import` in your browser and login using your Franz account details. Ferdi-server will create a new user with the same credentials and copy your Franz settings, services and workspaces.

## Transferring user data

Please refer to <https://github.com/getferdi/ferdi/wiki/Transferring-data-between-servers>

## Creating and using custom recipes

ferdi-server allows to extends the Franz recipe catalogue with custom Ferdi recipes.
Ferdi-server allows to extends the Franz recipe catalogue with custom Ferdi recipes.

For documentation on how to create a recipe, please visit [the official guide by Franz](https://github.com/meetfranz/plugins/blob/master/docs/integration.md).

To add your recipe to ferdi-server, open `http://[YOUR FERDI-SERVER]/new` in your browser. You can now define the following settings:
To add your recipe to Ferdi-server, open `http://[YOUR FERDI-SERVER]/new` in your browser. You can now define the following settings:

- `Author`: Author who created the recipe
- `Name`: Name for your new service. Can contain spaces and unicode characters
- `Service ID`: Unique ID for this recipe. Does not contain spaces or special characters (e.g. `google-drive`)
- `Link to SVG image`: Direct link to a 1024x1024 SVG that is used as a logo inside the store. Please use jsDelivr when using a file uploaded to GitHub as raw.githubusercontent files won't load
- `Recipe files`: Recipe files that you created using the [Franz recipe creation guide](https://github.com/meetfranz/plugins/blob/master/docs/integration.md). Please do *not* package your files beforehand - upload the raw files (you can drag and drop multiple files). ferdi-server will automatically package and store the recipe in the right format. Please also do not drag and drop or select the whole folder, select the individual files.
- `Link to SVG image`: Direct link to a 1024x1024 SVG image that is used as a logo inside the store. Please use jsDelivr when using a file uploaded to GitHub as raw.githubusercontent files won't load
- `Recipe files`: Recipe files that you created using the [Franz recipe creation guide](https://github.com/meetfranz/plugins/blob/master/docs/integration.md). Please do *not* package your files beforehand - upload the raw files (you can drag and drop multiple files). Ferdi-server will automatically package and store the recipe in the right format. Please also do not drag and drop or select the whole folder, select the individual files.
### Listing custom recipes
Inside Ferdi, searching for `ferdi:custom` will list all your custom recipes.
Inside Ferdi, searching for `ferdi:custom` will list all of your custom recipes.
## Contributing to ferdi-server's development
## Contributing to Ferdi-server's development

We welcome all contributors. Please read the [contributing guidelines](CONTRIBUTING.md) to setup your development machine and proceed.

## License

ferdi-server is licensed under the MIT License
Ferdi-server is licensed under the MIT License
7 changes: 4 additions & 3 deletions config/database.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require("path");

/** @type {import('@adonisjs/framework/src/Env')} */
const Env = use('Env');
Expand Down Expand Up @@ -31,7 +32,7 @@ module.exports = {
sqlite: {
client: 'sqlite3',
connection: {
filename: Helpers.appRoot(`${Env.get('DATA_DIR', 'database')}/${Env.get('DB_DATABASE', 'development')}.sqlite`),
filename: path.join(Env.get('DATA_DIR', 'data'), `${Env.get('DB_DATABASE', 'ferdi')}.sqlite`),
},
useNullAsDefault: true,
debug: Env.get('DB_DEBUG', false),
Expand All @@ -54,7 +55,7 @@ module.exports = {
port: Env.get('DB_PORT', ''),
user: Env.get('DB_USER', 'root'),
password: Env.get('DB_PASSWORD', ''),
database: Env.get('DB_DATABASE', 'adonis'),
database: Env.get('DB_DATABASE', 'ferdi'),
},
debug: Env.get('DB_DEBUG', false),
},
Expand All @@ -76,7 +77,7 @@ module.exports = {
port: Env.get('DB_PORT', ''),
user: Env.get('DB_USER', 'root'),
password: Env.get('DB_PASSWORD', ''),
database: Env.get('DB_DATABASE', 'adonis'),
database: Env.get('DB_DATABASE', 'ferdi'),
ssl: JSON.parse(Env.get('DB_SSL', 'true')),
},
debug: Env.get('DB_DEBUG', false),
Expand Down
1 change: 1 addition & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit 2b3b2ae

Please sign in to comment.