diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9dea3eb --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +dev/ diff --git a/.gitignore b/.gitignore index 21ea63d..cb619e0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ go.work.sum dist/ dev/data/ -KEY_FILE +dev/KEY_FILE +dev/tsauthkey.env diff --git a/Dockerfile.local b/Dockerfile.local index dcb8f68..4f78dd3 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -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 diff --git a/Makefile b/Makefile index 4a5e4df..a906706 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 9a06c73..769bc72 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -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: @@ -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 diff --git a/docker-compose.yaml b/docker-compose.yaml index 89d904a..7ce7398 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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