Skip to content

Commit 75743c4

Browse files
committed
04-rwslotmachine4: Add Dockerfile
Signed-off-by: Amalia Ionescu <ionescu.amalia98@gmail.com>
1 parent 2d21544 commit 75743c4

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Stage 1: Build
2+
FROM ubuntu:22.04 AS builder
3+
4+
WORKDIR /app
5+
6+
RUN set -xe; \
7+
apt-get -yqq update; \
8+
apt-get -yqq install build-essential \
9+
;
10+
11+
COPY ./rwslotmachine4.c .
12+
COPY ./Makefile .
13+
14+
RUN make
15+
16+
# Stage 2: Runtime
17+
FROM ubuntu:22.04
18+
19+
RUN set -xe; \
20+
apt-get -yqq update;\
21+
apt-get -yqq install libstdc++6; \
22+
rm -rf /var/lib/apt/lists/* \
23+
;
24+
25+
WORKDIR /app
26+
27+
# Copy compiled binary from builder stage
28+
COPY --from=builder /app/rwslotmachine4 .
29+
30+
# Expose port
31+
EXPOSE 31347
32+
33+
# Run the executable
34+
CMD ["/app/rwslotmachine4"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TARGET = rwslotmachine4
2+
3+
all: $(TARGET)
4+
5+
$(TARGET): rwslotmachine4.c
6+
gcc -o $(TARGET) rwslotmachine4.c
7+
8+
clean:
9+
rm -f $(TARGET)
10+
11+
.PHONY: all clean
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Building and Running
2+
3+
1. Build the Docker image:
4+
```bash
5+
docker build -t rwslotmachine4 -f Dockerfile .
6+
```
7+
8+
2. Run a Docker instance from the Docker image:
9+
```bash
10+
docker run -d --rm -p 31347:31337 --name rwslotmachine4-cnt -t rwslotmachine4
11+
```

0 commit comments

Comments
 (0)