File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
chapters/mitigations-and-defensive-strategies/defense-mechanisms/activities/05-rwslotmachine5/sol Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ # --- Build ---
2+ FROM gcc:latest AS builder
3+
4+ # Set working directory
5+ WORKDIR /app
6+
7+ # Copy the source code
8+ COPY ./rwslotmachine5.c .
9+
10+ # Build the C program
11+ RUN gcc -o rwslotmachine5 rwslotmachine5.c
12+
13+ # --- Runtime ---
14+ FROM ubuntu:22.04
15+
16+ # Install minimal libraries needed for runtime
17+ RUN apt-get update && apt-get install -y libstdc++6 && rm -rf /var/lib/apt/lists/*
18+
19+ # Set working directory
20+ WORKDIR /app
21+
22+ # Copy compiled binary from builder stage
23+ COPY --from=builder /app/rwslotmachine5 .
24+
25+ # Expose port
26+ EXPOSE 31348
27+
28+ # Run the executable
29+ CMD ["/app/rwslotmachine5" ]
Original file line number Diff line number Diff line change 1+ PORT ?= 31348
2+ IMG_NAME ?= rwslotmachine5
3+ CONT_NAME ?= $(IMG_NAME ) -cnt
4+
5+ build :
6+ docker build -t $(IMG_NAME ) -f Dockerfile .
7+
8+ run : build
9+ docker run -d -p $(PORT ) :31348 --name $(CONT_NAME ) -t $(IMG_NAME )
10+
11+ stop :
12+ -docker stop $(CONT_NAME )
13+
14+ clean : stop
15+ docker rm $(CONT_NAME )
16+
17+ .PHONY : build run stop clean
You can’t perform that action at this time.
0 commit comments