open-education-hub / web-security

Security Summer School, Web track
https://security-summer-school.github.io/web/
Other
24 stars 12 forks source link

Add common Makefile #32

Open gabrielmocanu opened 2 years ago

gabrielmocanu commented 2 years ago

Since Makefile is always 90% the same as the others my proposal is to use a general Makefile.

It should be something like:

INTERNAL_PORT := 80
CONT_NAME := ${IMG_NAME}

build:
    docker build -t $(IMG_NAME) -f Dockerfile ..

run: build
    docker run -d -p $(EXTERNAL_PORT):$(INTERNAL_PORT) --name $(CONT_NAME) -t $(IMG_NAME)

stop:
    docker stop $(CONT_NAME)

clean: stop
    docker rm $(IMG_NAME)
    docker image rm $(IMG_NAME):latest

.PHONY: build run stop clean

It should contain a delete rule for the file with the flag. It should be placed in the root of the repo in the common folder, something like challenge.mk. Then in this Makefile for each challenge we should only import and assign the variables:

EXTERNAL_PORT := 8001
IMG_NAME := sss-essentials-04_eyes

include ../../../../common/challenge.mk

This is an example from the essentials repo.

CC: @carrrina for visibility.

carrrina commented 1 year ago

@gabrielmocanu isn't this done?

gabrielmocanu commented 1 year ago

Not right now, we have a Makefile for each challenge. The issue was about introducing a single core Makefile and including it in another Makefile for each challenge without putting all rules. Right now, I don't know what is the best method.

razvand commented 1 year ago

As we talked on Discord, I think the best way is to have a common Makefile that will be placed somewhere (../../../../common/) that will be symlinked in each challenge directory.

The reasoning for the symlink is to simplify the exporting of the challenge as an archive (by solving the symlink).

carrrina commented 1 year ago

OK, so you mean like it is done in the template-public repo? The activity Makefile references the common Makefile.

razvand commented 1 year ago

OK, so you mean like it is done in the template-public repo? The activity Makefile references the common Makefile.

Yes, that one. But I would symlink it in the local challenge directory. And the include line will turn into:

include activity.mk