Rename HTTP base path to HTTP root
This commit is contained in:
parent
4168cb150c
commit
13224f75ea
|
@ -30,6 +30,6 @@ COPY --from=go-builder /app/clipper /bin/clipper
|
||||||
COPY --from=go-builder /root/go/bin/migrate /bin/migrate
|
COPY --from=go-builder /root/go/bin/migrate /bin/migrate
|
||||||
COPY --from=node-builder /app/build /app/assets
|
COPY --from=node-builder /app/build /app/assets
|
||||||
|
|
||||||
ENV ASSETS_HTTP_BASE_PATH "/app/assets"
|
ENV ASSETS_HTTP_ROOT "/app/assets"
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/clipper"]
|
ENTRYPOINT ["/bin/clipper"]
|
||||||
|
|
|
@ -7,7 +7,7 @@ DATABASE_URL=
|
||||||
|
|
||||||
# Optional. If set, files in this location will be served over HTTP at /.
|
# Optional. If set, files in this location will be served over HTTP at /.
|
||||||
# Mostly useful for deployment.
|
# Mostly useful for deployment.
|
||||||
ASSETS_HTTP_BASE_PATH=
|
ASSETS_HTTP_ROOT=
|
||||||
|
|
||||||
# Set the store type - either s3 or filesystem. Defaults to filesystem. The S3
|
# Set the store type - either s3 or filesystem. Defaults to filesystem. The S3
|
||||||
# store is recommended for production usage.
|
# store is recommended for production usage.
|
||||||
|
@ -16,7 +16,7 @@ ASSETS_HTTP_BASE_PATH=
|
||||||
FILE_STORE=filesystem
|
FILE_STORE=filesystem
|
||||||
|
|
||||||
# The base path for the file system store.
|
# The base path for the file system store.
|
||||||
FILE_STORE_HTTP_BASE_PATH=data/
|
FILE_STORE_HTTP_ROOT=data/
|
||||||
|
|
||||||
# AWS credentials, required for the S3 store.
|
# AWS credentials, required for the S3 store.
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
|
|
|
@ -101,5 +101,5 @@ func buildFileStore(ctx context.Context, c config.Config, logger *zap.Logger) (m
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("Initializing file sysytem store")
|
logger.Info("Initializing file sysytem store")
|
||||||
return filestore.NewFileSystemStore(c.FileStoreHTTPBasePath, "/")
|
return filestore.NewFileSystemStore(c.FileStoreHTTPRoot, "/")
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,12 @@ type Config struct {
|
||||||
TLSKeyFile string
|
TLSKeyFile string
|
||||||
DatabaseURL string
|
DatabaseURL string
|
||||||
FileStore FileStore
|
FileStore FileStore
|
||||||
FileStoreHTTPBasePath string
|
FileStoreHTTPRoot string
|
||||||
AWSAccessKeyID string
|
AWSAccessKeyID string
|
||||||
AWSSecretAccessKey string
|
AWSSecretAccessKey string
|
||||||
AWSRegion string
|
AWSRegion string
|
||||||
S3Bucket string
|
S3Bucket string
|
||||||
AssetsHTTPBasePath string
|
AssetsHTTPRoot string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFromEnv() (Config, error) {
|
func NewFromEnv() (Config, error) {
|
||||||
|
@ -76,7 +76,7 @@ func NewFromEnv() (Config, error) {
|
||||||
return Config{}, fmt.Errorf("invalid FILE_STORE value: %s", fileStoreString)
|
return Config{}, fmt.Errorf("invalid FILE_STORE value: %s", fileStoreString)
|
||||||
}
|
}
|
||||||
|
|
||||||
var awsAccessKeyID, awsSecretAccessKey, awsRegion, s3Bucket, fileStoreHTTPBasePath string
|
var awsAccessKeyID, awsSecretAccessKey, awsRegion, s3Bucket, fileStoreHTTPRoot string
|
||||||
if fileStore == S3Store {
|
if fileStore == S3Store {
|
||||||
awsAccessKeyID = os.Getenv("AWS_ACCESS_KEY_ID")
|
awsAccessKeyID = os.Getenv("AWS_ACCESS_KEY_ID")
|
||||||
if awsAccessKeyID == "" {
|
if awsAccessKeyID == "" {
|
||||||
|
@ -98,12 +98,12 @@ func NewFromEnv() (Config, error) {
|
||||||
return Config{}, errors.New("S3_BUCKET not set")
|
return Config{}, errors.New("S3_BUCKET not set")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if fileStoreHTTPBasePath = os.Getenv("FILE_STORE_HTTP_BASE_PATH"); fileStoreHTTPBasePath == "" {
|
if fileStoreHTTPRoot = os.Getenv("FILE_STORE_HTTP_ROOT"); fileStoreHTTPRoot == "" {
|
||||||
return Config{}, errors.New("FILE_STORE_HTTP_BASE_PATH not set")
|
return Config{}, errors.New("FILE_STORE_HTTP_ROOT not set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assetsHTTPBasePath := os.Getenv("ASSETS_HTTP_BASE_PATH")
|
assetsHTTPRoot := os.Getenv("ASSETS_HTTP_ROOT")
|
||||||
|
|
||||||
return Config{
|
return Config{
|
||||||
Environment: env,
|
Environment: env,
|
||||||
|
@ -116,7 +116,7 @@ func NewFromEnv() (Config, error) {
|
||||||
AWSSecretAccessKey: awsSecretAccessKey,
|
AWSSecretAccessKey: awsSecretAccessKey,
|
||||||
AWSRegion: awsRegion,
|
AWSRegion: awsRegion,
|
||||||
S3Bucket: s3Bucket,
|
S3Bucket: s3Bucket,
|
||||||
AssetsHTTPBasePath: assetsHTTPBasePath,
|
AssetsHTTPRoot: assetsHTTPRoot,
|
||||||
FileStoreHTTPBasePath: fileStoreHTTPBasePath,
|
FileStoreHTTPRoot: fileStoreHTTPRoot,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,13 +251,13 @@ func Start(options Options) error {
|
||||||
|
|
||||||
// Enabling the file system store disables serving assets over HTTP.
|
// Enabling the file system store disables serving assets over HTTP.
|
||||||
// TODO: fix this.
|
// TODO: fix this.
|
||||||
if options.Config.AssetsHTTPBasePath != "" {
|
if options.Config.AssetsHTTPRoot != "" {
|
||||||
log.With("basePath", options.Config.AssetsHTTPBasePath).Info("Configured to serve assets over HTTP")
|
log.With("root", options.Config.AssetsHTTPRoot).Info("Configured to serve assets over HTTP")
|
||||||
fileHandler = http.FileServer(http.Dir(options.Config.AssetsHTTPBasePath))
|
fileHandler = http.FileServer(http.Dir(options.Config.AssetsHTTPRoot))
|
||||||
}
|
}
|
||||||
if options.Config.FileStoreHTTPBasePath != "" {
|
if options.Config.FileStoreHTTPRoot != "" {
|
||||||
log.With("basePath", options.Config.FileStoreHTTPBasePath).Info("Configured to serve file store over HTTP")
|
log.With("root", options.Config.FileStoreHTTPRoot).Info("Configured to serve file store over HTTP")
|
||||||
fileHandler = http.FileServer(http.Dir(options.Config.FileStoreHTTPBasePath))
|
fileHandler = http.FileServer(http.Dir(options.Config.FileStoreHTTPRoot))
|
||||||
}
|
}
|
||||||
|
|
||||||
httpServer := http.Server{
|
httpServer := http.Server{
|
||||||
|
|
Loading…
Reference in New Issue