Skip to content

Commit 1f2b72a

Browse files
committed
chore(web-basics): update surprise challenge
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
1 parent 906054e commit 1f2b72a

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Stage 1: Generate the source file with the flag
2+
FROM alpine:latest AS builder
3+
4+
ARG FLAG
5+
COPY src/main.template.py /tmp/main.template.py
6+
RUN sed "s/__TEMPLATE__/${FLAG}/g" /tmp/main.template.py > /tmp/main.py
7+
8+
# Stage 2: Final image
19
FROM tiangolo/uwsgi-nginx-flask:python3.8
210

311
# copy over our requirements.txt file
@@ -6,5 +14,5 @@ COPY src/requirements.txt /tmp/
614
# upgrade pip and install required python packages
715
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt && mkdir app
816

9-
# copy over our app code
10-
COPY src/main.py /app
17+
# copy the generated source file from builder stage
18+
COPY --from=builder /tmp/main.py /app
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
EXTERNAL_PORT := 8093
2-
IMG_NAME := sss-web-01_surprise
3-
FILE_TEMPLATE := ../src/main.template.py
4-
FILE_SRC := ../src/main.py
2+
INTERNAL_PORT := 80
3+
NAME := web-basics_surprise
4+
FLAG := $(shell cat ../flag)
55

6-
include activity.mk
6+
run: build
7+
docker run -d -p $(EXTERNAL_PORT):$(INTERNAL_PORT) --name $(NAME) -t $(NAME)
8+
9+
build:
10+
docker build --build-arg FLAG=$(FLAG) -t $(NAME) -f Dockerfile ..
11+
12+
stop:
13+
docker stop $(NAME)
14+
15+
clean: stop
16+
docker rm $(NAME)
17+
docker image rm $(NAME):latest
18+
19+
.PHONY: run build stop clean

chapters/web-application-security/web-basics/drills/surprise/deploy/activity.mk

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)