mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
update documentation, docker and ansible files
This commit is contained in:
parent
ddc913ba7c
commit
1f7546789a
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ ansible/inventory
|
|||||||
ansible/passwords/
|
ansible/passwords/
|
||||||
build/
|
build/
|
||||||
.idea/
|
.idea/
|
||||||
|
docker/dev/config/config.hjson
|
||||||
|
14
README.md
vendored
14
README.md
vendored
@ -54,6 +54,7 @@ Front Page|Post
|
|||||||
+ [Requirements](#requirements)
|
+ [Requirements](#requirements)
|
||||||
+ [Set up Postgres DB](#set-up-postgres-db)
|
+ [Set up Postgres DB](#set-up-postgres-db)
|
||||||
+ [Running](#running)
|
+ [Running](#running)
|
||||||
|
- [Configuration](#configuration)
|
||||||
- [Documentation](#documentation)
|
- [Documentation](#documentation)
|
||||||
- [Support](#support)
|
- [Support](#support)
|
||||||
- [Translations](#translations)
|
- [Translations](#translations)
|
||||||
@ -222,6 +223,19 @@ cd lemmy
|
|||||||
# cd server && cargo watch -x run
|
# 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
|
## Documentation
|
||||||
|
|
||||||
- [Websocket API for App developers](docs/api.md)
|
- [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}}
|
template: src={{item.src}} dest={{item.dest}}
|
||||||
with_items:
|
with_items:
|
||||||
- { src: 'templates/env', dest: '/lemmy/.env' }
|
- { 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: '../docker/prod/docker-compose.yml', dest: '/lemmy/docker-compose.yml' }
|
||||||
- { src: 'templates/nginx.conf', dest: '/etc/nginx/sites-enabled/lemmy.conf' }
|
- { src: 'templates/nginx.conf', dest: '/etc/nginx/sites-enabled/lemmy.conf' }
|
||||||
vars:
|
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_PASSWORD={{ postgres_password }}
|
||||||
DATABASE_URL=postgres://lemmy:{{ postgres_password }}@lemmy_db:5432/lemmy
|
LEMMY_FRONT_END_DIR=/app/dist
|
||||||
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 }}
|
|
||||||
|
22
docker/dev/.env
vendored
22
docker/dev/.env
vendored
@ -1,17 +1,5 @@
|
|||||||
DOMAIN=my_domain
|
LEMMY_DOMAIN=my_domain
|
||||||
DATABASE_PASSWORD=password
|
LEMMY_DATABASE_PASSWORD=password
|
||||||
DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
LEMMY_DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
||||||
JWT_SECRET=changeme
|
LEMMY_JWT_SECRET=changeme
|
||||||
|
LEMMY_FRONT_END_DIR=/app/dist
|
||||||
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>
|
|
||||||
|
2
docker/dev/Dockerfile
vendored
2
docker/dev/Dockerfile
vendored
@ -38,8 +38,10 @@ FROM alpine:3.10
|
|||||||
RUN apk add libpq
|
RUN apk add libpq
|
||||||
|
|
||||||
# Copy resources
|
# Copy resources
|
||||||
|
COPY server/config /config
|
||||||
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy
|
COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy
|
||||||
COPY --from=node /app/ui/dist /app/dist
|
COPY --from=node /app/ui/dist /app/dist
|
||||||
|
|
||||||
RUN addgroup -g 1000 lemmy
|
RUN addgroup -g 1000 lemmy
|
||||||
RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
|
RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
|
||||||
RUN chown lemmy:lemmy /app/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
|
RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
|
||||||
|
|
||||||
# Copy resources
|
# Copy resources
|
||||||
|
COPY server/config /app/config
|
||||||
COPY --from=rust /app/server/ready /app/lemmy
|
COPY --from=rust /app/server/ready /app/lemmy
|
||||||
COPY --from=node /app/ui/dist /app/dist
|
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
|
RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
|
||||||
|
|
||||||
# Copy resources
|
# Copy resources
|
||||||
|
COPY server/config /config
|
||||||
COPY --from=rust /app/server/ready /app/lemmy
|
COPY --from=rust /app/server/ready /app/lemmy
|
||||||
COPY --from=node /app/ui/dist /app/dist
|
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
|
RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
|
||||||
|
|
||||||
# Copy resources
|
# Copy resources
|
||||||
|
COPY server/config /app/config
|
||||||
COPY --from=rust /app/server/ready /app/lemmy
|
COPY --from=rust /app/server/ready /app/lemmy
|
||||||
COPY --from=node /app/ui/dist /app/dist
|
COPY --from=node /app/ui/dist /app/dist
|
||||||
|
|
||||||
RUN chown lemmy:lemmy /app/lemmy
|
RUN chown lemmy:lemmy /app/lemmy
|
||||||
USER lemmy
|
USER lemmy
|
||||||
EXPOSE 8536
|
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
|
image: postgres:12-alpine
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=lemmy
|
- POSTGRES_USER=lemmy
|
||||||
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
|
- POSTGRES_PASSWORD=${LEMMY_DATABASE_PASSWORD}
|
||||||
- POSTGRES_DB=lemmy
|
- POSTGRES_DB=lemmy
|
||||||
volumes:
|
volumes:
|
||||||
- lemmy_db:/var/lib/postgresql/data
|
- lemmy_db:/var/lib/postgresql/data
|
||||||
@ -16,22 +16,11 @@ services:
|
|||||||
dockerfile: docker/dev/Dockerfile
|
dockerfile: docker/dev/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8536:8536"
|
- "127.0.0.1:8536:8536"
|
||||||
environment:
|
env_file:
|
||||||
- LEMMY_FRONT_END_DIR=/app/dist
|
- .env
|
||||||
- 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}
|
|
||||||
restart: always
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./config/config.hjson:/config/config.hjson:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- lemmy_db
|
- lemmy_db
|
||||||
lemmy_pictshare:
|
lemmy_pictshare:
|
||||||
|
6
docker/k8s/lemmy.yml
vendored
6
docker/k8s/lemmy.yml
vendored
@ -14,13 +14,13 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- env:
|
- env:
|
||||||
- name: DATABASE_URL
|
- name: LEMMY_DATABASE_URL
|
||||||
# example: 'postgres://lemmy:password@db:5432/lemmy'
|
# example: 'postgres://lemmy:password@db:5432/lemmy'
|
||||||
value: CHANGE_ME
|
value: CHANGE_ME
|
||||||
- name: HOSTNAME
|
- name: LEMMY_HOSTNAME
|
||||||
# example: 'lemmy.example.com'
|
# example: 'lemmy.example.com'
|
||||||
value: CHANGE_ME
|
value: CHANGE_ME
|
||||||
- name: JWT_SECRET
|
- name: LEMMY_JWT_SECRET
|
||||||
# example: 'very-super-good-secret'
|
# example: 'very-super-good-secret'
|
||||||
value: CHANGE_ME
|
value: CHANGE_ME
|
||||||
- name: LEMMY_FRONT_END_DIR
|
- name: LEMMY_FRONT_END_DIR
|
||||||
|
22
docker/prod/.env
vendored
22
docker/prod/.env
vendored
@ -1,17 +1,5 @@
|
|||||||
DOMAIN=my_domain
|
LEMMY_DOMAIN=my_domain
|
||||||
DATABASE_PASSWORD=password
|
LEMMY_DATABASE_PASSWORD=password
|
||||||
DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
LEMMY_DATABASE_URL=postgres://lemmy:password@lemmy_db:5432/lemmy
|
||||||
JWT_SECRET=changeme
|
LEMMY_JWT_SECRET=changeme
|
||||||
|
LEMMY_FRONT_END_DIR=/app/dist
|
||||||
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>
|
|
||||||
|
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
|
image: dessalines/lemmy:v0.5.0.3
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8536:8536"
|
- "127.0.0.1:8536:8536"
|
||||||
environment:
|
env_file:
|
||||||
- LEMMY_FRONT_END_DIR=/app/dist
|
- .env
|
||||||
- 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}
|
|
||||||
restart: always
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./config.hjson:/config/config.hjson:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- lemmy_db
|
- lemmy_db
|
||||||
lemmy_pictshare:
|
lemmy_pictshare:
|
||||||
|
@ -5,7 +5,7 @@ use std::env;
|
|||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
static CONFIG_FILE_DEFAULTS: &str = "config/defaults.hjson";
|
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)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
@ -59,21 +59,18 @@ impl Settings {
|
|||||||
|
|
||||||
/// Reads config from the files and environment.
|
/// Reads config from the files and environment.
|
||||||
/// First, defaults are loaded from CONFIG_FILE_DEFAULTS, then these values can be overwritten
|
/// First, defaults are loaded from CONFIG_FILE_DEFAULTS, then these values can be overwritten
|
||||||
/// from CONFIG_FILE_COSTUMIZED (optional). Finally, values from the environment
|
/// from CONFIG_FILE (optional). Finally, values from the environment (with prefix LEMMY) are
|
||||||
/// (with prefix LEMMY) are added to the config.
|
/// added to the config.
|
||||||
fn init() -> Result<Self, ConfigError> {
|
fn init() -> Result<Self, ConfigError> {
|
||||||
let mut s = Config::new();
|
let mut s = Config::new();
|
||||||
|
|
||||||
// Start off by merging in the "default" configuration file
|
|
||||||
s.merge(File::with_name(CONFIG_FILE_DEFAULTS))?;
|
s.merge(File::with_name(CONFIG_FILE_DEFAULTS))?;
|
||||||
|
|
||||||
// TODO: we could also automatically load dev/prod configs based on environment
|
s.merge(File::with_name(CONFIG_FILE).required(false))?;
|
||||||
// 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))?;
|
|
||||||
|
|
||||||
// Add in settings from the environment (with a prefix of LEMMY)
|
// Add in settings from the environment (with a prefix of LEMMY)
|
||||||
// Eg.. `LEMMY_DEBUG=1 ./target/app` would set the `debug` key
|
// 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();
|
return s.try_into();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user