From 9e321658ede754876b6e18ef1ce1d3e53f8da2f2 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Fri, 23 Mar 2018 15:26:38 +0000 Subject: [PATCH] make s3 configurable via env vars --- .../filestore/config/settings.defaults.coffee | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/services/filestore/config/settings.defaults.coffee b/services/filestore/config/settings.defaults.coffee index bb4a885478..673c411462 100644 --- a/services/filestore/config/settings.defaults.coffee +++ b/services/filestore/config/settings.defaults.coffee @@ -1,6 +1,6 @@ Path = require "path" -module.exports = +settings = internal: filestore: port: 3009 @@ -11,22 +11,26 @@ module.exports = # Choices are # s3 - Amazon S3 # fs - local filesystem - backend: "fs" - stores: - # where to store user and template binary files - # - # For Amazon S3 this is the bucket name to store binary files in. - # - # For local filesystem this is the directory to store the files in. - # Must contain full path, e.g. "/var/lib/sharelatex/data". - # This path must exist, not be tmpfs and be writable to by the user sharelatex is run as. - user_files: Path.resolve(__dirname + "/../user_files") - public_files: Path.resolve(__dirname + "/../public_files") - template_files: Path.resolve(__dirname + "/../template_files") - # if you are using S3, then fill in your S3 details below - # s3: - # key: "" - # secret: "" + if process.env['AWS_KEY']? + backend: "s3" + s3: + key: process.env['AWS_KEY'] + secret: process.env['AWS_SECRET'] + stores: + user_files: process.env['AWS_S3_USER_FILES_BUCKET_NAME'] + template_files: process.env['AWS_S3_TEMPLATE_FILES_BUCKET_NAME'] + public_files: process.env['AWS_S3_PUBLIC_FILES_BUCKET_NAME'] + else + backend: "fs" + stores: + # + # For local filesystem this is the directory to store the files in. + # Must contain full path, e.g. "/var/lib/sharelatex/data". + # This path must exist, not be tmpfs and be writable to by the user sharelatex is run as. + user_files: Path.resolve(__dirname + "/../user_files") + public_files: Path.resolve(__dirname + "/../public_files") + template_files: Path.resolve(__dirname + "/../template_files") + path: uploadFolder: Path.resolve(__dirname + "/../uploads") @@ -35,9 +39,15 @@ module.exports = # Any commands to wrap the convert utility in, for example ["nice"], or ["firejail", "--profile=/etc/firejail/convert.profile"] convertCommandPrefix: [] - # Filestore health check - # ---------------------- - # Project and file details to check in persistor when calling /health_check - # health_check: - # project_id: "" - # file_id: "" + +# Filestore health check +# ---------------------- +# Project and file details to check in persistor when calling /health_check +if process.env['HEALTH_CHECK_PROJECT_ID']? and process.env['HEALTH_CHECK_FILE_ID']? + settings.health_check = + project_id: process.env['HEALTH_CHECK_PROJECT_ID'] + file_id: process.env['HEALTH_CHECK_FILE_ID'] + +module.exports = settings + +console.log module.exports \ No newline at end of file