Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Binary
chat-server

# Database
chat.db

# Uploads
uploads/

# IDE
.vscode/
.idea/

# OS
.DS_Store
Thumbs.db
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@
FROM golang:1.21 AS builder
WORKDIR /app

RUN apt-get update && apt-get install -y gcc sqlite3 libsqlite3-dev

# Copy go.mod and go.sum for dependency caching
COPY go.mod go.sum ./
RUN go mod download

# Copy all source files
COPY . .

# Build server and client binaries
RUN go build -o chat-server ./server.go
RUN go build -o chat-client ./client.go
# Build server binary
RUN CGO_ENABLED=1 go build -o chat-server ./cmd/server

# Stage 2: Runtime
FROM debian:bullseye-slim
WORKDIR /app

RUN apt-get update && apt-get install -y ca-certificates sqlite3 && rm -rf /var/lib/apt/lists/*

# Copy binaries from builder
COPY --from=builder /app/chat-server .
COPY --from=builder /app/chat-client .
COPY --from=builder /app/public ./public

RUN mkdir -p uploads

# Expose server port
EXPOSE 8080
Expand Down
Loading