-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
feat: add a makefile for local docker env setup #3417
base: master
Are you sure you want to change the base?
Changes from all commits
ca37ef3
c03759f
48c7818
c82ca31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Makefile | ||
|
||
APP_NAME=asyncapi-website | ||
CONTAINER_NAME=asyncapi-website-container | ||
PORT=3000 | ||
|
||
# Build, Run, and Show Logs | ||
run: | ||
@echo "Building Docker image..." | ||
@docker build -t $(APP_NAME) . | ||
@echo "Stopping and removing any existing container..." | ||
@docker stop $(CONTAINER_NAME) || true | ||
@docker rm $(CONTAINER_NAME) || true | ||
@echo "Starting Docker container..." | ||
@docker run -d --name $(CONTAINER_NAME) -v "$$(pwd)":/async -p $(PORT):$(PORT) $(APP_NAME) | ||
@sleep 2 # Allow container to start | ||
@echo "Displaying Docker logs..." | ||
@docker logs -f $(CONTAINER_NAME) | ||
Comment on lines
+8
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Separate build and run targets for better modularity. The Apply this diff to restructure the targets: +.PHONY: build run clean
+
+# Build Docker Image
+build:
+ @echo "Building Docker image..."
+ @docker build -t $(APP_NAME) -f $(DOCKER_FILE) $(DOCKER_CONTEXT)
+
# Build, Run, and Show Logs
-run:
- @echo "Building Docker image..."
- @docker build -t $(APP_NAME) .
+run: build
@echo "Stopping and removing any existing container..."
@docker stop $(CONTAINER_NAME) || true
@docker rm $(CONTAINER_NAME) || true
|
||
|
||
# Clean Docker Images | ||
clean: | ||
@echo "Cleaning up Docker images..." | ||
@docker rmi $(APP_NAME) || true | ||
@docker system prune -f || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make variables configurable and add essential Docker settings.
The variables should be overridable from the command line, and additional Docker-related settings would be beneficial.
Apply this diff to improve variable declarations:
📝 Committable suggestion