From 5c7f3a4acae19c1671ad2a3beb03172d2fcc12be Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Tue, 16 Jun 2026 22:50:19 +0700 Subject: [PATCH] updates --- .gitignore | 1 + Dockerfile.builder | 2 ++ Makefile | 14 ++++++++++++-- README.md | 7 +++++++ docker-compose.yml | 31 +++++++++++++++++++++++++++++-- 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.builder diff --git a/.gitignore b/.gitignore index 111f379..b6fbbf2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ # Dependency directories (remove the comment below to include it) # vendor/ +bin/ # Go workspace file go.work diff --git a/Dockerfile.builder b/Dockerfile.builder new file mode 100644 index 0000000..71560b6 --- /dev/null +++ b/Dockerfile.builder @@ -0,0 +1,2 @@ +FROM golang:1.26-alpine +RUN apk add --no-cache gcc musl-dev diff --git a/Makefile b/Makefile index c4b8635..4007b5f 100644 --- a/Makefile +++ b/Makefile @@ -12,5 +12,15 @@ generate: run: go run ./cmd/${REPO_NAME_SNAKE}/main.go -build: - go build -o bin/${REPO_NAME_SNAKE} cmd/${REPO_NAME_SNAKE}/main.go +build-builder: + docker build -f Dockerfile.builder -t my-go-builder . + +build-linux: + docker run --rm \ + -v "$$PWD":/app \ + -w /app \ + my-go-builder sh -c \ + "GOOS=linux GOARCH=arm64 go build -o bin/${REPO_NAME_SNAKE}_linux_arm64 cmd/${REPO_NAME_SNAKE}/main.go" + +test: + go test -count=1 ./... diff --git a/README.md b/README.md index 803308e..50626b6 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,10 @@ go mod tidy ```shell make run ``` + +Сборка + +```shell +make build-builder +make build-linux +``` diff --git a/docker-compose.yml b/docker-compose.yml index 1c432e7..e3e967f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,9 @@ version: '3.8' +networks: + app_network: + driver: bridge + services: ${REPO_NAME}: build: @@ -7,5 +11,28 @@ services: dockerfile: Dockerfile ports: - "8080:8080" -# environment: -# - ENV_VAR_NAME=env_var_value + environment: + - DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/${REPO_NAME_SNAKE}?sslmode=disable" + depends_on: + - postgres + restart: unless-stopped + networks: + - app_network + + postgres: + image: postgres:18 + container_name: postgres18 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ${REPO_NAME_SNAKE} + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + restart: unless-stopped + networks: + - app_network + +volumes: + postgres_data: