Skip to content

Commit e64bf0f

Browse files
authored
Merge pull request #13 from vivek-pk/Added-Docker
Added Docker build
2 parents c43ff09 + e1e1f67 commit e64bf0f

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Stage 1: Build the Go binary
2+
FROM golang:1.23.1-alpine AS builder
3+
4+
# Install dependencies
5+
RUN apk add --no-cache git
6+
7+
# Set the working directory
8+
WORKDIR /GoAdBlock
9+
10+
# Copy Go modules files and download dependencies
11+
COPY go.mod go.sum ./
12+
13+
# Copy the source code
14+
COPY . .
15+
16+
# Build the Go application
17+
RUN go build -o GoAdBlock ./cmd/server/main.go
18+
19+
# Stage 2: Create a minimal runtime image
20+
FROM alpine:latest
21+
22+
RUN adduser -D goadblock && mkdir /GoAdBlock
23+
# Set the working directory
24+
WORKDIR /GoAdBlock/
25+
26+
# Copy the binary from the builder stage
27+
COPY --from=builder /GoAdBlock/GoAdBlock .
28+
29+
# Set execution permissions
30+
RUN chmod +x GoAdBlock
31+
EXPOSE 8080 53
32+
# Command to run the app
33+
CMD ["./GoAdBlock"]

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: "3"
2+
services:
3+
adgoblock:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
ports:
8+
- "53:53"
9+
- "8080:8080"

0 commit comments

Comments
 (0)