Skip to content

Commit

Permalink
add docker image with wgo to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidapaulopt committed Nov 8, 2024
1 parent d96c334 commit 4696a16
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default: dev
default: dev_docker

# Change these variables as necessary.
MAIN_PACKAGE_PATH := "cmd/server/main.go"
Expand Down Expand Up @@ -109,6 +109,22 @@ server_start:
docker_start:
cd dev && docker compose -f docker-compose-local.yaml up -d

## dev_docker: start the dev docker containers
.PHONY: dev_docker
dev_docker:
CURRENT_UID=$(shell id -u):$(shell id -g) docker compose -f dev/docker-compose-dev.yaml up

## dev_docker_stop: stop the dev docker containers
.PHONY: dev_docker_stop
dev_docker_stop:
CURRENT_UID=$(shell id -u):$(shell id -g) docker compose -f dev/docker-compose-dev.yaml down


## dev_image: generate docker development image
.PHONY: dev_image
dev_image:
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) -f dev/Dockerfile.dev -t devimage .

## docker_stop: stop the docker containers
.PHONY: docker_stop
docker_stop:
Expand All @@ -119,6 +135,7 @@ docker_stop:
.PHONY: stop
stop: dev_kill docker_stop


## docker_image: Create docker image
.PHONY: docker_image
docker_image:
Expand Down
2 changes: 1 addition & 1 deletion config/tsdproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dashboard:
name: DASH1
datadir: ./dev/data
log:
level: debug
level: info
21 changes: 21 additions & 0 deletions dev/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dockerfile.dev
#
FROM golang:1.23.3

WORKDIR /app

#ARG UID=1000
#ARG GID=1000

#RUN groupadd -g $GID appgroup && useradd -l -m -u $UID -g appgroup appuser


#USER appuser
RUN go install github.com/bokwoon95/wgo@latest

COPY go.mod go.sum /app/

RUN go mod download

CMD ["wgo", "run", "cmd/server/main.go"]

21 changes: 21 additions & 0 deletions dev/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
dev:
image: devimage
ports:
- "8080:8080"
volumes:
- ..:/app
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
restart: unless-stopped
# user: ${CURRENT_UID}
secrets:
- authkey

volumes:
tsdata:
tmp:

secrets:
authkey:
file: ./KEY_FILE
4 changes: 3 additions & 1 deletion dev/docker-compose-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ services:
- 81:80
labels:
- tsdproxy.enable=true
- tsdproxy.name=teste
- tsdproxy.name=testeff
- tsdproxy.ephemeral=true
- tsdproxy.funnel=true
networks:
- c1

Expand Down
5 changes: 4 additions & 1 deletion dev/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ services:
environment:
- TSDPROXY_AUTHKEYFILE=/run/secrets/authkey
- DOCKER_HOST=unix:///var/run/docker.sock
- TSDPROXY_HOSTNAME=192.168.43.149
- TSDPROXY_LOG_LEVEL=trace
secrets:
- authkey
labels:
- tsdproxy.enable=true
- tsdproxy.name=dash-dev

c1:
image: nginx
Expand Down

0 comments on commit 4696a16

Please sign in to comment.