init commit. Makefile. Dokerimage, Dockerfile, Docker-compose.yaml

This commit is contained in:
valitovgaziz
2024-08-04 22:40:36 +05:00
commit 0487e3771a
8 changed files with 82 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=postgres
DB_PORT=5432
HOST_DB=db
SERVER_PORT=8000
+10
View File
@@ -0,0 +1,10 @@
build:
@docker compose build
run: build
@docker compose up
clean:
@docker builder prune
.DEFAULT_GOAL=run
+11
View File
@@ -0,0 +1,11 @@
FROM golang:1.22.5
WORKDIR /app
COPY . .
RUN go mod tidy
RUN go build -o bin/api.exe cmd/main.go
ENTRYPOINT [ "bin/api.exe" ]
BIN
View File
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
func main() {
r := chi.NewRouter()
r.Use(middleware.Logger)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("welcome developer"))
})
http.ListenAndServe(":8000", r)
}
+5
View File
@@ -0,0 +1,5 @@
module api
go 1.22.5
require github.com/go-chi/chi/v5 v5.1.0
+2
View File
@@ -0,0 +1,2 @@
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
+31
View File
@@ -0,0 +1,31 @@
services:
# db:
# image: postgres:16
# env_file:
# - .env
# environment:
# - POSTGRES_USER=${DB_USER}
# - POSTGRES_PASSWORD=${DB_PASSWORD}
# - POSTGRES_DB=${DB_NAME}
# ports:
# - "${DB_PORT}:${DB_PORT}"
# volumes:
# - postgres-db:/var/lib/postgresql/data
api:
build:
context: ./api
dockerfile: Dockerfile
env_file:
- .env
ports:
- "${SERVER_PORT}:${SERVER_PORT}"
volumes:
- .:/usr/src/app
# depends_on:
# - db
# volumes:
# postgres-db: