Skip to content

Commit 3ee6c90

Browse files
authored
Merge pull request #26 from filecoin-project/feat/tls-uploads
feat: tls uploads
2 parents 4602e55 + 79ebd49 commit 3ee6c90

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM golang:buster as builder
22

3+
RUN apt-get update && apt-get install -y ca-certificates
4+
35
ENV GO111MODULE=on \
46
CGO_ENABLED=1 \
57
GOOS=linux \
@@ -17,6 +19,7 @@ RUN go build -o filecoin-chain-archiver ./cmd/filecoin-chain-archiver
1719

1820
FROM debian:buster
1921

22+
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
2023
COPY --from=builder /build/filecoin-chain-archiver /usr/local/bin
2124

2225
ENTRYPOINT ["/usr/local/bin/filecoin-chain-archiver"]

cmd/filecoin-chain-archiver/cmds/create.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ import (
77
"fmt"
88
"io"
99
"io/ioutil"
10+
"net/url"
1011
"strings"
1112
"syscall"
1213
"time"
1314

14-
"github.com/filecoin-project/go-state-types/abi"
15-
"github.com/minio/minio-go/v7"
16-
"github.com/minio/minio-go/v7/pkg/credentials"
1715
"github.com/filecoin-project/filecoin-chain-archiver/pkg/config"
1816
"github.com/filecoin-project/filecoin-chain-archiver/pkg/consensus"
1917
"github.com/filecoin-project/filecoin-chain-archiver/pkg/export"
2018
"github.com/filecoin-project/filecoin-chain-archiver/pkg/nodelocker/client"
19+
"github.com/filecoin-project/go-state-types/abi"
20+
"github.com/minio/minio-go/v7"
21+
"github.com/minio/minio-go/v7/pkg/credentials"
2122
"github.com/urfave/cli/v2"
2223
"golang.org/x/xerrors"
2324

@@ -140,6 +141,11 @@ var cmdCreate = &cli.Command{
140141
flagAfter := cctx.Int("after")
141142
flagStaterootCount := cctx.Int("stateroot-count")
142143

144+
u, err := url.Parse(flagBucketEndpoint)
145+
if err != nil {
146+
return err
147+
}
148+
143149
icfg, err := config.FromFile(flagConfigPath, &config.Config{})
144150
if err != nil {
145151
return err
@@ -298,9 +304,20 @@ var cmdCreate = &cli.Command{
298304
logger.Infow("discarding output")
299305
io.Copy(ioutil.Discard, r)
300306
} else {
301-
minioClient, err := minio.New(flagBucketEndpoint, &minio.Options{
307+
host := u.Host
308+
port := u.Port()
309+
if port == "" {
310+
port = "80"
311+
if u.Scheme == "https" {
312+
port = "443"
313+
}
314+
}
315+
316+
logger.Infow("upload endpoint", "host", host, "port", port, "tls", u.Scheme == "https")
317+
318+
minioClient, err := minio.New(fmt.Sprintf("%s:%s", host, port), &minio.Options{
302319
Creds: credentials.NewStaticV4(flagBucketAccessKey, flagBucketSecretKey, ""),
303-
Secure: false,
320+
Secure: u.Scheme == "https",
304321
})
305322

306323
info, err := minioClient.PutObject(ctx, flagBucket, fmt.Sprintf("%d.car", height), tr, -1, minio.PutObjectOptions{})

0 commit comments

Comments
 (0)