File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .git
2+ .github
3+ .gitignore
4+ README.md
5+ Dockerfile
6+ .dockerignore
7+
8+ * .log
9+ tmp /
10+ dist /
11+ bin /
12+ coverage.out
Original file line number Diff line number Diff line change 1+ # -------Build stage-------
2+ FROM golang:1.26-alpine AS builder
3+
4+ WORKDIR /app
5+
6+ COPY go.mod ./
7+ COPY *.go ./
8+
9+ RUN CGO_ENABLED=0 GOOS=linux go build -o http-server .
10+
11+
12+ # -------Runtime stage-------
13+ FROM alpine:3.23
14+
15+ WORKDIR /app
16+
17+ COPY --from=builder /app/http-server .
18+
19+ EXPOSE 8080
20+
21+ CMD ["./http-server" ]
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ http-server-devops/
3030## Tasks
3131
3232- [x] Task 1: HTTP Server
33- - [ ] Task 2: Dockerize
33+ - [x ] Task 2: Dockerize
3434- [ ] Task 3: CI/CD Pipeline
3535- [ ] Task 4: Kubernetes Deployment
3636- [ ] Task 5: Terraform Configuration
@@ -64,3 +64,33 @@ Run tests:
6464``` bash
6565go test ./...
6666```
67+
68+ ## Docker Usage
69+
70+ ### Build image
71+
72+ ``` bash
73+ docker build -t http-server-devops:local .
74+ ```
75+
76+ ### Run container
77+
78+ ``` bash
79+ docker run --rm -p 8080:8080 http-server-devops:local
80+ ```
81+
82+ ### Test container
83+
84+ ``` bash
85+ curl http://localhost:8080/
86+ ```
87+
88+ ### Run with custom port
89+
90+ ``` bash
91+ docker run --rm -p 9090:9090 -e PORT=9090 http-server-devops:local
92+ ```
93+
94+ ``` bash
95+ curl http://localhost:9090/
96+ ```
You can’t perform that action at this time.
0 commit comments