From 2b539ed123b994985be73731d7bbe4165c617f55 Mon Sep 17 00:00:00 2001 From: JordanSussman Date: Wed, 20 Feb 2019 22:17:50 -0600 Subject: [PATCH] feat(s3): allow user to specify s3 endpoint for non aws usage --- cmd/drone-server/config/config.go | 5 +++-- cmd/drone-server/inject_store.go | 1 + docker/Dockerfile.agent.linux.amd64 | 4 ++-- docker/Dockerfile.controller.linux.amd64 | 4 ++-- docker/Dockerfile.controller.linux.arm | 4 ++-- docker/Dockerfile.controller.linux.arm64 | 4 ++-- docker/Dockerfile.server.linux.amd64 | 4 ++-- docker/Dockerfile.server.linux.arm | 4 ++-- docker/Dockerfile.server.linux.arm64 | 4 ++-- store/logs/s3.go | 6 ++++-- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cmd/drone-server/config/config.go b/cmd/drone-server/config/config.go index 9f005aa9..9b6a5a3f 100644 --- a/cmd/drone-server/config/config.go +++ b/cmd/drone-server/config/config.go @@ -330,8 +330,9 @@ type ( // S3 provides the storage configuration. S3 struct { - Bucket string `envconfig:"DRONE_S3_BUCKET"` - Prefix string `envconfig:"DRONE_S3_PREFIX"` + Bucket string `envconfig:"DRONE_S3_BUCKET"` + Prefix string `envconfig:"DRONE_S3_PREFIX"` + Endpoint string `envconfig:"DRONE_S3_ENDPOINT"` } // HTTP provides http configuration. diff --git a/cmd/drone-server/inject_store.go b/cmd/drone-server/inject_store.go index 0698252b..367e8db1 100644 --- a/cmd/drone-server/inject_store.go +++ b/cmd/drone-server/inject_store.go @@ -85,6 +85,7 @@ func provideLogStore(db *db.DB, config config.Config) core.LogStore { return logs.NewS3Env( config.S3.Bucket, config.S3.Prefix, + config.S3.Endpoint, ) } diff --git a/docker/Dockerfile.agent.linux.amd64 b/docker/Dockerfile.agent.linux.amd64 index 0f8826db..14f657bc 100644 --- a/docker/Dockerfile.agent.linux.amd64 +++ b/docker/Dockerfile.agent.linux.amd64 @@ -1,7 +1,7 @@ -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 ENV GODEBUG netdns=go ENV DRONE_RUNNER_OS=linux ENV DRONE_RUNNER_ARCH=amd64 diff --git a/docker/Dockerfile.controller.linux.amd64 b/docker/Dockerfile.controller.linux.amd64 index 18e99213..cf1db6fd 100644 --- a/docker/Dockerfile.controller.linux.amd64 +++ b/docker/Dockerfile.controller.linux.amd64 @@ -1,7 +1,7 @@ -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 ENV GODEBUG netdns=go ENV DRONE_RUNNER_OS=linux ENV DRONE_RUNNER_ARCH=amd64 diff --git a/docker/Dockerfile.controller.linux.arm b/docker/Dockerfile.controller.linux.arm index 86a0016b..873ee782 100644 --- a/docker/Dockerfile.controller.linux.arm +++ b/docker/Dockerfile.controller.linux.arm @@ -1,7 +1,7 @@ -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 ENV GODEBUG=netdns=go ENV DRONE_RUNNER_OS=linux ENV DRONE_RUNNER_ARCH=arm diff --git a/docker/Dockerfile.controller.linux.arm64 b/docker/Dockerfile.controller.linux.arm64 index b215c93f..54afa687 100644 --- a/docker/Dockerfile.controller.linux.arm64 +++ b/docker/Dockerfile.controller.linux.arm64 @@ -1,7 +1,7 @@ -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 ENV GODEBUG=netdns=go ENV DRONE_RUNNER_OS=linux ENV DRONE_RUNNER_ARCH=arm64 diff --git a/docker/Dockerfile.server.linux.amd64 b/docker/Dockerfile.server.linux.amd64 index f04b0b68..fbab5049 100644 --- a/docker/Dockerfile.server.linux.amd64 +++ b/docker/Dockerfile.server.linux.amd64 @@ -1,9 +1,9 @@ # docker build --rm -f docker/Dockerfile -t drone/drone . -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 EXPOSE 80 443 VOLUME /data diff --git a/docker/Dockerfile.server.linux.arm b/docker/Dockerfile.server.linux.arm index 1625c437..e577b602 100644 --- a/docker/Dockerfile.server.linux.arm +++ b/docker/Dockerfile.server.linux.arm @@ -1,9 +1,9 @@ # docker build --rm -f docker/Dockerfile -t drone/drone . -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 EXPOSE 80 443 VOLUME /data diff --git a/docker/Dockerfile.server.linux.arm64 b/docker/Dockerfile.server.linux.arm64 index fde955b4..35264c30 100644 --- a/docker/Dockerfile.server.linux.arm64 +++ b/docker/Dockerfile.server.linux.arm64 @@ -1,9 +1,9 @@ # docker build --rm -f docker/Dockerfile -t drone/drone . -FROM alpine:3.6 as alpine +FROM alpine:3.9 as alpine RUN apk add -U --no-cache ca-certificates -FROM alpine:3.6 +FROM alpine:3.9 EXPOSE 80 443 VOLUME /data diff --git a/store/logs/s3.go b/store/logs/s3.go index 680007b1..320305ea 100644 --- a/store/logs/s3.go +++ b/store/logs/s3.go @@ -22,12 +22,14 @@ import ( // s3gof3r as an alternate. github.com/rlmcpherson/s3gof3r // NewS3Env returns a new S3 log store. -func NewS3Env(bucket, prefix string) core.LogStore { +func NewS3Env(bucket, prefix, endpoint string) core.LogStore { return &s3store{ bucket: bucket, prefix: prefix, session: session.Must( - session.NewSession(), + session.NewSession(&aws.Config{ + Endpoint: aws.String(endpoint), + }), ), } }