mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-05 04:00:02 +00:00
update documentation, docker and ansible files
This commit is contained in:
parent
140eff181c
commit
f7333705dc
16 changed files with 65 additions and 89 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ ansible/inventory
|
|||
ansible/passwords/
|
||||
build/
|
||||
.idea/
|
||||
docker/dev/config/config.hjson
|
||||
|
|
14
README.md
vendored
14
README.md
vendored
|
@ -54,6 +54,7 @@ Front Page|Post
|
|||
+ [Requirements](#requirements)
|
||||
+ [Set up Postgres DB](#set-up-postgres-db)
|
||||
+ [Running](#running)
|
||||
- [Configuration](#configuration)
|
||||
- [Documentation](#documentation)
|
||||
- [Support](#support)
|
||||
- [Translations](#translations)
|
||||
|
@ -222,6 +223,19 @@ cd lemmy
|
|||
# cd server && cargo watch -x run
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration is based on the file [defaults.hjson](server/config/defaults.hjson). This file also contains
|
||||
documentation for all the available options. To override the defaults, you can copy the options you want to change
|
||||
into your local `config.hjson` file.
|
||||
|
||||
Additionally, you can override any config files with environment variables. These have the same name as the config
|
||||
options, and are prefixed with `LEMMY_`. For example, you can override the `database.password` with
|
||||
`LEMMY_DATABASE_PASSWORD=my_password`.
|
||||
|
||||
An additional option `LEMMY_DATABASE_URL` is available, which can be used with a PostgreSQL connection string like
|
||||
`postgres://lemmy:password@lemmy_db:5432/lemmy`, passing all connection details at once.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Websocket API for App developers](docs/api.md)
|
||||
|
|
1
ansible/lemmy.yml
vendored
1
ansible/lemmy.yml
vendored
|
@ -33,6 +33,7 @@
|
|||
template: src={{item.src}} dest={{item.dest}}
|
||||
with_items:
|
||||
- { src: 'templates/env', dest: '/lemmy/.env' }
|
||||
- { src: 'templates/config.hjson', dest: '/lemmy/config.hjson' }
|
||||
- { src: '../docker/prod/docker-compose.yml', dest: '/lemmy/docker-compose.yml' }
|
||||
- { src: 'templates/nginx.conf', dest: '/etc/nginx/sites-enabled/lemmy.conf' }
|
||||
vars:
|
||||
|
|
13
ansible/templates/config.hjson
vendored
Normal file
13
ansible/templates/config.hjson
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
database: {
|
||||
password: "{{ postgres_password }}"
|
||||
}
|
||||
hostname: "{{ domain }}"
|
||||
jwt_secret: "{{ jwt_password }}"
|
||||
email: {
|
||||
smtp_server: "{{ smtp_server }}"
|
||||
smtp_login: "{{ smtp_login }}"
|
||||
smtp_password: "{{ smtp_password }}"
|
||||
smtp_from_address: "{{ smtp_from_address }}"
|
||||
}
|
||||
}
|
14
ansible/templates/env
vendored
14
ansible/templates/env
vendored
|
@ -1,14 +1,2 @@
|
|||
DOMAIN={{ domain }}
|
||||
DATABASE_PASSWORD={{ postgres_password }}
|
||||
DATABASE_URL=postgres://lemmy:{{ postgres_password }}@lemmy_db:5432/lemmy
|
||||
JWT_SECRET={{ jwt_password }}
|
||||
RATE_LIMIT_MESSAGE=30
|
||||
RATE_LIMIT_MESSAGE_PER_SECOND=60
|
||||
RATE_LIMIT_POST=3
|
||||
RATE_LIMIT_POST_PER_SECOND=600
|
||||
RATE_LIMIT_REGISTER=3
|
||||
RATE_LIMIT_REGISTER_PER_SECOND=3600
|
||||
SMTP_SERVER={{ smtp_server }}
|
||||
SMTP_LOGIN={{ smtp_login }}
|
||||
SMTP_PASSWORD={{ smtp_password }}
|
||||
SMTP_FROM_ADDRESS={{ smtp_from_address }}
|
||||
LEMMY_FRONT_END_DIR=/app/dist
|
||||
|
|
22
docker/dev/.env
vendored
22
docker/dev/.env
vendored
|
@ -1,17 +1,5 @@
|
|||
DOMAIN=my_domain
|
||||
DATABASE_PASSWORD=password
|
||||
DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
||||
JWT_SECRET=changeme
|
||||
|
||||
RATE_LIMIT_MESSAGE=30
|
||||
RATE_LIMIT_MESSAGE_PER_SECOND=60
|
||||
RATE_LIMIT_POST=6
|
||||
RATE_LIMIT_POST_PER_SECOND=600
|
||||
RATE_LIMIT_REGISTER=3
|
||||
RATE_LIMIT_REGISTER_PER_SECOND=3600
|
||||
|
||||
# Optional email fields
|
||||
SMTP_SERVER=
|
||||
SMTP_LOGIN=
|
||||
SMTP_PASSWORD=
|
||||
SMTP_FROM_ADDRESS=Domain.com Lemmy Admin <notifications@domain.com>
|
||||
LEMMY_DOMAIN=my_domain
|
||||
LEMMY_DATABASE_PASSWORD=password
|
||||
LEMMY_DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
||||
LEMMY_JWT_SECRET=changeme
|
||||
LEMMY_FRONT_END_DIR=/app/dist
|
||||
|
|
2
docker/dev/Dockerfile
vendored
2
docker/dev/Dockerfile
vendored
|
@ -38,8 +38,10 @@ FROM alpine:3.10
|
|||
RUN apk add libpq
|
||||
|
||||
# Copy resources
|
||||
COPY server/config /config
|
||||
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy
|
||||
COPY --from=node /app/ui/dist /app/dist
|
||||
|
||||
RUN addgroup -g 1000 lemmy
|
||||
RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
|
||||
RUN chown lemmy:lemmy /app/lemmy
|
||||
|
|
1
docker/dev/Dockerfile.aarch64
vendored
1
docker/dev/Dockerfile.aarch64
vendored
|
@ -69,6 +69,7 @@ RUN addgroup --gid 1000 lemmy
|
|||
RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
|
||||
|
||||
# Copy resources
|
||||
COPY server/config /app/config
|
||||
COPY --from=rust /app/server/ready /app/lemmy
|
||||
COPY --from=node /app/ui/dist /app/dist
|
||||
|
||||
|
|
1
docker/dev/Dockerfile.armv7hf
vendored
1
docker/dev/Dockerfile.armv7hf
vendored
|
@ -69,6 +69,7 @@ RUN addgroup --gid 1000 lemmy
|
|||
RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
|
||||
|
||||
# Copy resources
|
||||
COPY server/config /config
|
||||
COPY --from=rust /app/server/ready /app/lemmy
|
||||
COPY --from=node /app/ui/dist /app/dist
|
||||
|
||||
|
|
2
docker/dev/Dockerfile.libc
vendored
2
docker/dev/Dockerfile.libc
vendored
|
@ -65,8 +65,10 @@ RUN addgroup --gid 1000 lemmy
|
|||
RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
|
||||
|
||||
# Copy resources
|
||||
COPY server/config /app/config
|
||||
COPY --from=rust /app/server/ready /app/lemmy
|
||||
COPY --from=node /app/ui/dist /app/dist
|
||||
|
||||
RUN chown lemmy:lemmy /app/lemmy
|
||||
USER lemmy
|
||||
EXPOSE 8536
|
||||
|
|
2
docker/dev/config/config.hjson
vendored
Normal file
2
docker/dev/config/config.hjson
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
{
|
||||
}
|
21
docker/dev/docker-compose.yml
vendored
21
docker/dev/docker-compose.yml
vendored
|
@ -5,7 +5,7 @@ services:
|
|||
image: postgres:12-alpine
|
||||
environment:
|
||||
- POSTGRES_USER=lemmy
|
||||
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
|
||||
- POSTGRES_PASSWORD=${LEMMY_DATABASE_PASSWORD}
|
||||
- POSTGRES_DB=lemmy
|
||||
volumes:
|
||||
- lemmy_db:/var/lib/postgresql/data
|
||||
|
@ -16,22 +16,11 @@ services:
|
|||
dockerfile: docker/dev/Dockerfile
|
||||
ports:
|
||||
- "127.0.0.1:8536:8536"
|
||||
environment:
|
||||
- LEMMY_FRONT_END_DIR=/app/dist
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
- HOSTNAME=${DOMAIN}
|
||||
- RATE_LIMIT_MESSAGE=${RATE_LIMIT_MESSAGE}
|
||||
- RATE_LIMIT_MESSAGE_PER_SECOND=${RATE_LIMIT_MESSAGE_PER_SECOND}
|
||||
- RATE_LIMIT_POST=${RATE_LIMIT_POST}
|
||||
- RATE_LIMIT_POST_PER_SECOND=${RATE_LIMIT_POST_PER_SECOND}
|
||||
- RATE_LIMIT_REGISTER=${RATE_LIMIT_REGISTER}
|
||||
- RATE_LIMIT_REGISTER_PER_SECOND=${RATE_LIMIT_REGISTER_PER_SECOND}
|
||||
- SMTP_SERVER=${SMTP_SERVER}
|
||||
- SMTP_LOGIN=${SMTP_LOGIN}
|
||||
- SMTP_PASSWORD=${SMTP_PASSWORD}
|
||||
- SMTP_FROM_ADDRESS=${SMTP_FROM_ADDRESS}
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config/config.hjson:/config/config.hjson:ro
|
||||
depends_on:
|
||||
- lemmy_db
|
||||
lemmy_pictshare:
|
||||
|
|
6
docker/k8s/lemmy.yml
vendored
6
docker/k8s/lemmy.yml
vendored
|
@ -14,13 +14,13 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: DATABASE_URL
|
||||
- name: LEMMY_DATABASE_URL
|
||||
# example: 'postgres://lemmy:password@db:5432/lemmy'
|
||||
value: CHANGE_ME
|
||||
- name: HOSTNAME
|
||||
- name: LEMMY_HOSTNAME
|
||||
# example: 'lemmy.example.com'
|
||||
value: CHANGE_ME
|
||||
- name: JWT_SECRET
|
||||
- name: LEMMY_JWT_SECRET
|
||||
# example: 'very-super-good-secret'
|
||||
value: CHANGE_ME
|
||||
- name: LEMMY_FRONT_END_DIR
|
||||
|
|
22
docker/prod/.env
vendored
22
docker/prod/.env
vendored
|
@ -1,17 +1,5 @@
|
|||
DOMAIN=my_domain
|
||||
DATABASE_PASSWORD=password
|
||||
DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
||||
JWT_SECRET=changeme
|
||||
|
||||
RATE_LIMIT_MESSAGE=30
|
||||
RATE_LIMIT_MESSAGE_PER_SECOND=60
|
||||
RATE_LIMIT_POST=6
|
||||
RATE_LIMIT_POST_PER_SECOND=600
|
||||
RATE_LIMIT_REGISTER=3
|
||||
RATE_LIMIT_REGISTER_PER_SECOND=3600
|
||||
|
||||
# Optional email fields
|
||||
SMTP_SERVER=
|
||||
SMTP_LOGIN=
|
||||
SMTP_PASSWORD=
|
||||
SMTP_FROM_ADDRESS=Domain.com Lemmy Admin <notifications@domain.com>
|
||||
LEMMY_DOMAIN=my_domain
|
||||
LEMMY_DATABASE_PASSWORD=password
|
||||
LEMMY_DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
||||
LEMMY_JWT_SECRET=changeme
|
||||
LEMMY_FRONT_END_DIR=/app/dist
|
||||
|
|
19
docker/prod/docker-compose.yml
vendored
19
docker/prod/docker-compose.yml
vendored
|
@ -14,22 +14,11 @@ services:
|
|||
image: dessalines/lemmy:v0.5.0.3
|
||||
ports:
|
||||
- "127.0.0.1:8536:8536"
|
||||
environment:
|
||||
- LEMMY_FRONT_END_DIR=/app/dist
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
- HOSTNAME=${DOMAIN}
|
||||
- RATE_LIMIT_MESSAGE=${RATE_LIMIT_MESSAGE}
|
||||
- RATE_LIMIT_MESSAGE_PER_SECOND=${RATE_LIMIT_MESSAGE_PER_SECOND}
|
||||
- RATE_LIMIT_POST=${RATE_LIMIT_POST}
|
||||
- RATE_LIMIT_POST_PER_SECOND=${RATE_LIMIT_POST_PER_SECOND}
|
||||
- RATE_LIMIT_REGISTER=${RATE_LIMIT_REGISTER}
|
||||
- RATE_LIMIT_REGISTER_PER_SECOND=${RATE_LIMIT_REGISTER_PER_SECOND}
|
||||
- SMTP_SERVER=${SMTP_SERVER}
|
||||
- SMTP_LOGIN=${SMTP_LOGIN}
|
||||
- SMTP_PASSWORD=${SMTP_PASSWORD}
|
||||
- SMTP_FROM_ADDRESS=${SMTP_FROM_ADDRESS}
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config.hjson:/config/config.hjson:ro
|
||||
depends_on:
|
||||
- lemmy_db
|
||||
lemmy_pictshare:
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::env;
|
|||
use std::net::IpAddr;
|
||||
|
||||
static CONFIG_FILE_DEFAULTS: &str = "config/defaults.hjson";
|
||||
static CONFIG_FILE_COSTUMIZED: &str = "config/custom.hjson";
|
||||
static CONFIG_FILE: &str = "config/config.hjson";
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Settings {
|
||||
|
@ -59,21 +59,18 @@ impl Settings {
|
|||
|
||||
/// Reads config from the files and environment.
|
||||
/// First, defaults are loaded from CONFIG_FILE_DEFAULTS, then these values can be overwritten
|
||||
/// from CONFIG_FILE_COSTUMIZED (optional). Finally, values from the environment
|
||||
/// (with prefix LEMMY) are added to the config.
|
||||
/// from CONFIG_FILE (optional). Finally, values from the environment (with prefix LEMMY) are
|
||||
/// added to the config.
|
||||
fn init() -> Result<Self, ConfigError> {
|
||||
let mut s = Config::new();
|
||||
|
||||
// Start off by merging in the "default" configuration file
|
||||
s.merge(File::with_name(CONFIG_FILE_DEFAULTS))?;
|
||||
|
||||
// TODO: we could also automatically load dev/prod configs based on environment
|
||||
// https://github.com/mehcode/config-rs/blob/master/examples/hierarchical-env/src/settings.rs#L49
|
||||
s.merge(File::with_name(CONFIG_FILE_COSTUMIZED).required(false))?;
|
||||
s.merge(File::with_name(CONFIG_FILE).required(false))?;
|
||||
|
||||
// Add in settings from the environment (with a prefix of LEMMY)
|
||||
// Eg.. `LEMMY_DEBUG=1 ./target/app` would set the `debug` key
|
||||
s.merge(Environment::with_prefix("LEMMY"))?;
|
||||
s.merge(Environment::with_prefix("LEMMY").separator("_"))?;
|
||||
|
||||
return s.try_into();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue