aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Dockerfile7
-rw-r--r--docker-compose-test.yaml (renamed from docker-compose-travis.yaml)19
-rw-r--r--docker-compose.yaml2
-rw-r--r--hived.go11
4 files changed, 34 insertions, 5 deletions
diff --git a/Dockerfile b/Dockerfile
index 1cb0683..0a9e3e2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,4 @@
FROM alpine:3.13 as builder
-
RUN apk update && apk upgrade
RUN apk add go git
COPY go.* /hived/
@@ -7,7 +6,13 @@ RUN cd /hived && go mod download
COPY *.go /hived/
RUN cd /hived && go build
+FROM node:lts-alpine3.13 AS certbuilder
+RUN apk add openssl
+WORKDIR /certs
+RUN openssl req -nodes -new -x509 -subj="/C=US/ST=Denial/L=springfield/O=Dis/CN=localhost" -keyout server.key -out server.cert
+
FROM gcr.io/distroless/static-debian10
+COPY --from=certbuilder /cert/ /cert/
COPY --from=builder /hived/hived /hived/
COPY ./docker-entrypoint.sh /hived/
ENTRYPOINT ["/hived/docker-entrypoint.sh"]
diff --git a/docker-compose-travis.yaml b/docker-compose-test.yaml
index a5263e0..5040b2d 100644
--- a/docker-compose-travis.yaml
+++ b/docker-compose-test.yaml
@@ -4,6 +4,10 @@ services:
image: hived
build:
context: ./
+ secrets:
+ - tg_bot_token
+ - ch_api_key
+ - ch_api_secret
networks:
- hivednet
restart: unless-stopped
@@ -11,7 +15,11 @@ services:
- "8008:8008"
depends_on:
- redis
- entrypoint: /hived/hived
+ entrypoint: /hived/docker-entrypoint.sh
+ cap_drop:
+ - ALL
+ environment:
+ - SERVER_DEPLOYMENT_TYPE=test
redis:
image: redis:6.2-alpine
networks:
@@ -26,7 +34,12 @@ services:
networks:
hivednet:
driver: bridge
- routenet:
- driver: bridge
+secrets:
+ tg_bot_token:
+ file: ./tgtoken
+ ch_api_key:
+ file: ./changelly_api_key
+ ch_api_secret:
+ file: ./changelly_api_secret
volumes:
redis-data:
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 3be8194..ac7f223 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -20,6 +20,8 @@ services:
- /etc/letsencrypt/archive/api.terminaldweller.com/:/certs/
cap_drop:
- ALL
+ environment:
+ - SERVER_DEPLOYMENT_TYPE=deployment
redis:
image: redis:6.2-alpine
networks:
diff --git a/hived.go b/hived.go
index 7924206..5345e70 100644
--- a/hived.go
+++ b/hived.go
@@ -44,6 +44,7 @@ const (
TELEGRAM_BOT_TOKEN_ENV_VAR = "TELEGRAM_BOT_TOKEN"
CHANGELLY_API_KEY_ENV_VAR = "CHANGELLY_API_KEY"
CHANGELLY_API_SECRET_ENV_VAR = "CHANGELLY_API_SECRET"
+ SERVER_DEPLOYMENT_TYPE = "SERVER_DEPLOYMENT_TYPE"
)
func runTgBot() {
@@ -628,7 +629,15 @@ func startServer(gracefulWait time.Duration) {
r.HandleFunc("/crypto/robots.txt", robotsHandler)
go func() {
- if err := srv.ListenAndServeTLS("/certs/fullchain1.pem", "/certs/privkey1.pem"); err != nil {
+ var certPath, keyPath string
+ if os.Getenv(SERVER_DEPLOYMENT_TYPE) == "deployment" {
+ certPath = "/certs/fullchain1.pem"
+ keyPath = "/certs/privkey1.pem"
+ } else {
+ certPath = "/certs/server.cert"
+ keyPath = "/certs/server.key"
+ }
+ if err := srv.ListenAndServeTLS(certPath, keyPath); err != nil {
log.Fatal().Err(err)
}
}()