Hot reloading gin gonic with docker

This commit is contained in:
Leons Aleksandrovs
2025-07-05 21:22:18 +03:00
parent a42e61fb48
commit 8916f3e394
4 changed files with 10 additions and 1 deletions

View File

@@ -26,4 +26,9 @@ FROM base AS dev
# Install air for hot reloading
RUN go install github.com/air-verse/air@latest
# Copy code, and expose port
COPY . .
EXPOSE 8080
# Enable hot reloading for go
CMD [ "air" ]

1
backend/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
tmp

View File

@@ -27,7 +27,7 @@ func (u *User) Register(c *gin.Context) {
validate := validator.New()
if err := validate.Struct(data); err != nil {
// Handle error
log.Fatalf("Error: %v", err.Error())
log.Printf("[ERROR]: %v", err.Error())
}
// fmt.Println(data)

View File

@@ -3,9 +3,12 @@ services:
build:
context: ./backend
dockerfile: ../Dockerfile.backend
target: dev # Development mode with hot reload
restart: unless-stopped
container_name: cover-letter-backend
volumes:
- "./backend:/app"
environment:
- GIN_MODE=debug
# - GIN_MODE=release # For production