Created dockerfile and compose

This commit is contained in:
2025-11-17 01:47:26 +03:00
parent e42d492ef2
commit df7bf08099
3 changed files with 41 additions and 1 deletions

20
Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# Dockerfile
FROM golang:tip-alpine3.22 AS builder
WORKDIR /app
# RUN apk add --no-cache git ca-certificates
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
RUN go build -ldflags="-s -w" -o /app/echo .
FROM alpine:3.22
# RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates
RUN addgroup -S app && adduser -S app -G app
USER app
WORKDIR /app
COPY --from=builder /app/echo /app/echo
COPY --from=builder /app/front_files /app/front_files
# EXPOSE is optional with custom networking, we can keep or remove it as we are using custom network with compose
EXPOSE 8900
ENTRYPOINT ["/app/echo"]

19
docker-compose.yml Normal file
View File

@@ -0,0 +1,19 @@
services:
echo:
build:
context: .
dockerfile: Dockerfile
image: echo-image:latest
container_name: echo
restart: unless-stopped
ports:
- "8900:8900"
networks:
- echo-net
environment:
- TZ=UTC
networks:
echo-net:
name: echo-net

View File

@@ -7,6 +7,7 @@ import (
func main() { func main() {
fmt.Println("Hello from echo-echo-cho-o") fmt.Println("Hello from echo-echo-cho-o")
fmt.Println("Listening to port 8900")
api.BuildRouter("localhost:8080") api.BuildRouter(":8900")
} }