infra: add support for docker

This commit is contained in:
Muhammed Efe Cetin
2025-03-17 10:23:28 +03:00
committed by M. Efe Çetin
parent 94b2c702ce
commit 5a2a3e95ea
3 changed files with 32 additions and 6 deletions

25
Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
FROM golang:1.24-alpine AS builder
WORKDIR /src
# Copy go mod and project files
COPY go.* ./
RUN go mod download
COPY . .
# Install necessary dependencies
RUN apk update && apk add --no-cache git ca-certificates openssl && update-ca-certificates
# Build the binary
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o ./hastebin ./cmd/main.go
FROM gcr.io/distroless/static:nonroot
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Copy the binary from the builder stage
COPY --from=builder /src/hastebin /bin/hastebin
# Set the user and group
USER 0:0
CMD ["/bin/hastebin", "--config", "/app/config.yaml"]

View File

@@ -13,7 +13,7 @@ storage:
documents:
- key: "about"
path: "./about.md"
path: "/app/about.md"
rate_limiting:
enable: true

View File

@@ -3,10 +3,11 @@ services:
haste-server:
build: .
environment:
- STORAGE_TYPE=memcached
- STORAGE_HOST=memcached
- STORAGE_PORT=11211
- STORAGE_TYPE=file
- STORAGE_FILE_PATH=/app/pastes
ports:
- "7777:7777"
memcached:
image: memcached:latest
volumes:
- ./config.yaml:/app/config.yaml
- ./about.md:/app/about.md
- "./data:/app/pastes"