Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common Makefile #32

Open
gabrielmocanu opened this issue Jul 18, 2022 · 5 comments
Open

Add common Makefile #32

gabrielmocanu opened this issue Jul 18, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@gabrielmocanu
Copy link
Contributor

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.

@gabrielmocanu gabrielmocanu added the enhancement New feature or request label Jul 21, 2022
@carrrina
Copy link
Collaborator

carrrina commented Jul 2, 2023

@gabrielmocanu isn't this done?

@gabrielmocanu
Copy link
Contributor Author

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
Copy link
Contributor

razvand commented Jul 4, 2023

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
Copy link
Collaborator

carrrina commented Jul 4, 2023

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

@razvand
Copy link
Contributor

razvand commented Jul 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants