Skip to content

Commit

Permalink
add docker secret support to docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidapaulopt committed Oct 23, 2024
1 parent ca5ce87 commit f3e2781
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ go.work.sum

dist/
dev/data/
KEY_FILE
dev/KEY_FILE
dev/tsauthkey.env
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /app
COPY . .

# Compila a aplicação Go
RUN go mod download && CGO_ENABLED=0 GOOS=linux go build -o /tsdproxyd ./cmd/server/main.go
RUN go mod tidy && CGO_ENABLED=0 GOOS=linux go build -o /tsdproxyd ./cmd/server/main.go

# Usa uma imagem mínima para rodar a aplicação
FROM alpine:3.20
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ dev: docker_start server_start
.PHONY: server_start
server_start:
TSDPROXY_DataDir=./dev/data TSDPROXY_LOG_LEVEL=debug DOCKER_HOST=unix:///var/run/docker.sock \
TSDPROXY_AUTHKEYFILE=./KEY_FILE \
TSDPROXY_AUTHKEYFILE=./dev/KEY_FILE \
wgo run -file=.go -file=.yaml -file=.env -file=.json -file=.toml ${MAIN_PACKAGE_PATH}

## docker_start: start the docker containers
Expand Down
29 changes: 26 additions & 3 deletions dev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
services:
tailscale-docker-proxy:
image: tsdproxy:latest
container_name: tailscale-docker-proxy
ports:
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
restart: unless-stopped
environment:
- TSDPROXY_AUTHKEYFILE=/run/secrets/authkey
- TSDPROXY_DATADIR:/data
- DOCKER_HOST=unix:///var/run/docker.sock
secrets:
- authkey

c1:
image: nginx
# ports:
Expand All @@ -21,6 +37,13 @@ services:
network_mode: host
ports:
- 83:80
labels:
- tsdproxy.enable=true
# - tsdproxy.proxy.port=8083
# labels:
# - tsdproxy.enable=true
# - tsdproxy.proxy.port=8083

volumes:
tsdata:

secrets:
authkey:
file: ./KEY_FILE
27 changes: 6 additions & 21 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
---
services:
tailscale-tsdproxy:
image: tailscale/tailscale:latest
hostname: tailscale-tsdproxy
environment:
- TS_AUTHKEY=tskey-client-notAReal-OAuthClientSecret1Atawk
- TS_EXTRA_ARGS=--advertise-tags=tag:container
- TS_STATE_DIR=/var/lib/tailscale
- TS_USERSPACE=false
- TS_HOSTNAME=server
- TS_ROUTES=192.168.1.0/24
volumes:
- ${PWD}/tailscale-tsdproxy/state:/var/lib/tailscale
- /dev/net/tun:/dev/net/tun
cap_add:
- net_admin
- sys_module
restart: unless-stopped

tsdproxy:
image: almeidapaulopt/tsdproxy:latest
container_name: tsdproxy
ports:
- "80:8080"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- datadir:/data
restart: unless-stopped
depends_on:
- tailscale-tsdproxy
environment:
#- TSDPROXY_AUTHKEYFILE=/run/secrets/authkey
- TS_AUTHKEY=tskey-auth-is-not-actually-a-real-key
- TSDPROXY_DATADIR:/data
- DOCKER_HOST=unix:///var/run/docker.sock

volumes:
datadir:

secrets:
authkey:
file: ./KEY_FILE

0 comments on commit f3e2781

Please sign in to comment.