Skip to content

Commit

Permalink
feat: makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed May 27, 2024
1 parent b06d1ba commit 8b97a51
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ COPY turbo.json ./

COPY apps/app/package.json ./apps/app/package.json
COPY apps/app/prisma/schema.prisma apps/app/prisma/schema.prisma
COPY packages/lib/package.json ./packages/lib/package.json
COPY packages/emails/package.json ./packages/emails/package.json

RUN npm ci --omit=dev

Expand All @@ -39,6 +41,7 @@ COPY --from=deps /usr/src/app .
COPY apps/app ./apps/app
COPY packages/configs ./packages/configs
COPY packages/lib ./packages/lib
COPY packages/emails ./packages/emails


RUN turbo run build --filter=@next-boilerplate/app
Expand Down
37 changes: 37 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.PHONY: buildnrun bnr help

# The default goal is 'help'
.DEFAULT_GOAL := help

# Main build and run target
buildnrun:
@$(MAKE) -s _buildnrun CMD=$(filter-out $@,$(MAKECMDGOALS))

# Alias for buildnrun
bnr:
@$(MAKE) -s _buildnrun CMD=$(filter-out $@,$(MAKECMDGOALS))

# Internal buildnrun target
_buildnrun:
ifeq ($(CMD),app)
docker build -f apps/app/Dockerfile -t next-boilerplate/app --network host .
docker run -e PORT=8080 --network host next-boilerplate/app
else ifeq ($(CMD),landing)
docker build -f apps/landing/Dockerfile -t next-boilerplate/landing --network host .
docker run -e PORT=8080 --network host next-boilerplate/landing
else ifeq ($(CMD),cron)
docker build -f apps/cron/Dockerfile -t next-boilerplate/cron --network host .
docker run --network host next-boilerplate/cron
else
@echo "Please provide a valid target. List of available targets:"
@echo " - app"
@echo " - landing"
@echo " - cron
endif

# Help message
help:
@echo "Available commands:"
@echo " make buildnrun <target> - Build and run the Docker container for <targt>"
@echo " make bnr <target> - Alias for buildnrun <target>"
@echo " make help - Display this help message"

0 comments on commit 8b97a51

Please sign in to comment.