init commit. Makefile. Dokerimage, Dockerfile, Docker-compose.yaml
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_NAME=postgres
|
||||
DB_PORT=5432
|
||||
HOST_DB=db
|
||||
SERVER_PORT=8000
|
||||
@@ -0,0 +1,10 @@
|
||||
build:
|
||||
@docker compose build
|
||||
|
||||
run: build
|
||||
@docker compose up
|
||||
|
||||
clean:
|
||||
@docker builder prune
|
||||
|
||||
.DEFAULT_GOAL=run
|
||||
@@ -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" ]
|
||||
Binary file not shown.
@@ -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)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
module api
|
||||
|
||||
go 1.22.5
|
||||
|
||||
require github.com/go-chi/chi/v5 v5.1.0
|
||||
@@ -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=
|
||||
@@ -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:
|
||||
Reference in New Issue
Block a user