Skip to content

Commit bc29e03

Browse files
committed
add local file storage support
1 parent dd89d45 commit bc29e03

File tree

9 files changed

+60
-7
lines changed

9 files changed

+60
-7
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ clean-docker: stop
3030
${docker-compose} rm -fsv || true
3131

3232
clean-conf:
33-
rm -rfv env.* .env docker-compose.yml config/uc/fixtures/*.json
33+
rm -rfv env.* .env docker-compose.yml config/uc/fixtures/*.json \
34+
config/nginx
3435

3536
clean-data: clean-docker
36-
rm -rfv ./data/certs ./data/minio_root ./data/pgdata ./data/uc
37+
rm -rfv ./data/certs ./data/minio_root \
38+
./data/pgdata ./data/uc ./data/outline
3739

3840
clean: clean-docker clean-conf

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The config file [scripts/config.sh.sample](scripts/config.sh.sample)
3232
- `make start` start outline
3333
- `make stop` stop outline
3434
- `make clean` remove all config file generated by script.
35-
- `make clean-data` ⚠️ You will lost all your data
35+
- `make clean-data` ⚠️ You will lose all your data
3636
3737
3838
## FAQ

scripts/config.sh.sample

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Outline Wiki 0.72.0-1 supports local file storage.
2+
# Specify what storage system to use. Possible value is one of "s3" or "local".
3+
# For "local", the avatar images and document attachments will be saved on local disk.
4+
FILE_STORAGE=s3
15
# The url used to vist this web site.
26
URL=http://127.0.0.1:8888
37
# The default interface language. See translate.getoutline.com for a list of
@@ -14,7 +18,7 @@ FORCE_HTTPS=false
1418
ALLOWED_DOMAINS=
1519

1620
# Docker image version
17-
OUTLINE_VERSION=0.67.2
21+
OUTLINE_VERSION=0.72.0-3
1822
POSTGRES_VERSION=15.2-alpine3.17
1923
MINIO_VERSION=RELEASE.2022-11-17T23-20-09Z
2024
MINIO_MC_VERSION=RELEASE.2022-11-17T21-20-39Z

scripts/main.sh

+18-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# update config file
77
MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-`openssl rand -hex 8`}
88
MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-`openssl rand -hex 32`}
9+
# Should be: OIDC_CLIENT_SECRET=${OIDC_CLIENT_SECRET:-`openssl rand -hex 28`}
10+
# To maintain compatibility with old version, do not fix this bug.
911
OIDC_CLIENT_SECRET=${MINIO_SECRET_KEY:-`openssl rand -hex 28`}
1012
OUTLINE_SECRET_KEY=${OUTLINE_SECRET_KEY:-`openssl rand -hex 32`}
1113
OUTLINE_UTILS_SECRET=${OUTLINE_UTILS_SECRET:-`openssl rand -hex 32`}
@@ -54,6 +56,7 @@ function create_outline_env_file {
5456
env_replace UTILS_SECRET $OUTLINE_UTILS_SECRET $env_file
5557
env_replace DEFAULT_LANGUAGE $DEFAULT_LANGUAGE $env_file
5658
env_replace FORCE_HTTPS $FORCE_HTTPS $env_file
59+
env_replace FILE_STORAGE $FILE_STORAGE $env_file
5760

5861
env_delete DATABASE_URL $env_file
5962
env_delete DATABASE_URL_TEST $env_file
@@ -70,7 +73,6 @@ function create_outline_env_file {
7073
env_replace AWS_SECRET_ACCESS_KEY $MINIO_SECRET_KEY $env_file
7174
env_replace AWS_S3_UPLOAD_BUCKET_URL $URL $env_file
7275

73-
env_add PGSSLMODE disable $env_file
7476
env_add ALLOWED_DOMAINS "$ALLOWED_DOMAINS" $env_file
7577
}
7678

@@ -104,13 +106,23 @@ function create_uc_db_init_file {
104106

105107
function create_env_files {
106108
create_global_env_file
107-
create_minio_env_file
109+
# DISABLE_MINIO
110+
if [ $FILE_STORAGE == "s3" ]; then
111+
create_minio_env_file
112+
fi
108113
create_outline_env_file
109114
create_oidc_env_file
110115
create_uc_env_file
111116
create_uc_db_init_file
112117
}
113118

119+
function create_apps_config {
120+
cp -r ./templates/config/* ../config/
121+
if [ $FILE_STORAGE != "s3" ]; then
122+
rm_block "MINIO" "../config/nginx/default.conf"
123+
fi
124+
}
125+
114126
function create_docker_compose_file {
115127
fn=docker-compose.yml
116128
file=../$fn
@@ -119,12 +131,16 @@ function create_docker_compose_file {
119131
env_tmpl_replace NETWORKS "$NETWORKS" $file
120132
env_tmpl_replace MINIO_ACCESS_KEY "$MINIO_ACCESS_KEY" $file
121133
env_tmpl_replace MINIO_SECRET_KEY "$MINIO_SECRET_KEY" $file
134+
if [ "$FILE_STORAGE" != "s3" ]; then
135+
rm_block "MINIO" $file
136+
fi
122137
}
123138

124139
function init_cfg {
125140
update_config_file
126141
create_docker_compose_file
127142
create_env_files
143+
create_apps_config
128144
}
129145

130146
function reload_nginx {

config/nginx/default.conf renamed to scripts/templates/config/nginx/default.conf

+2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ server {
22
listen 80;
33
client_max_body_size 100m;
44

5+
##BEGIN MINIO
56
# Proxy requests to the bucket "outline" to MinIO server running on port 9000
67
location /outline-bucket {
78
include /etc/nginx/conf.d/include/proxy.conf;
89
proxy_pass http://wk-minio:9000;
910
}
11+
##END
1012

1113
# Outline Wiki
1214
location / {

scripts/templates/docker-compose.yml

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
restart: always
1717
networks:
1818
- ${NETWORKS}
19+
##BEGIN MINIO
1920
wk-minio:
2021
image: minio/minio:${MINIO_VERSION}
2122
volumes:
@@ -42,6 +43,7 @@ services:
4243
"
4344
networks:
4445
- ${NETWORKS}
46+
##END
4547
wk-outline:
4648
image: outlinewiki/outline:${OUTLINE_VERSION}
4749
command: sh -c "yarn db:migrate --env production-ssl-disabled && yarn start"
@@ -53,11 +55,15 @@ services:
5355
env_file:
5456
- ./env.outline
5557
- ./env.oidc
58+
volumes:
59+
- ./data/outline:/var/lib/outline/data
5660
restart: always
5761
depends_on:
5862
- wk-postgres
5963
- wk-redis
64+
##BEGIN MINIO
6065
- wk-minio
66+
##END
6167
networks:
6268
- ${NETWORKS}
6369
wk-oidc-server:
@@ -80,7 +86,9 @@ services:
8086
- ./data/uc/static_root:/uc/static_root:ro
8187
restart: always
8288
depends_on:
89+
##BEGIN MINIO
8390
- wk-minio
91+
##END
8492
- wk-outline
8593
- wk-oidc-server
8694
networks:

scripts/templates/env.outline

+16-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ AWS_ACCESS_KEY_ID=get_a_key_from_aws
5353
AWS_SECRET_ACCESS_KEY=get_the_secret_of_above_key
5454
AWS_REGION=xx-xxxx-x
5555
AWS_S3_UPLOAD_BUCKET_URL=http://s3:4569
56-
AWS_S3_UPLOAD_BUCKET_NAME=bucket_name_here
56+
AWS_S3_UPLOAD_BUCKET_NAME=outline-bucket
5757
AWS_S3_UPLOAD_MAX_SIZE=26214400
5858
AWS_S3_FORCE_PATH_STYLE=true
5959
# uploaded s3 objects permission level, default is private
@@ -74,3 +74,18 @@ SMTP_REPLY_EMAIL=
7474
# See translate.getoutline.com for a list of available language codes and their
7575
# percentage translated.
7676
DEFAULT_LANGUAGE=en_US
77+
78+
# Specify what storage system to use. Possible value is one of "s3" or "local".
79+
# For "local", the avatar images and document attachments will be saved on local disk.
80+
FILE_STORAGE=local
81+
82+
# If "local" is configured for FILE_STORAGE above, then this sets the parent directory under
83+
# which all attachments/images go. Make sure that the process has permissions to create
84+
# this path and also to write files to it.
85+
FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data
86+
87+
# Maximum allowed size for the uploaded attachment.
88+
FILE_STORAGE_UPLOAD_MAX_SIZE=26214400
89+
90+
# Disable SSL for connecting to Postgres
91+
PGSSLMODE=disable

scripts/utils.sh

+6
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ function env_delete {
4545
filename=$2
4646
sed "/${key}/d" -i $filename
4747
}
48+
49+
function rm_block {
50+
block=$1
51+
filename=$2
52+
sed "/##BEGIN ${block}/,/##END/d" -i $filename
53+
}

0 commit comments

Comments
 (0)