smm_tg/Makefile

53 lines
1.7 KiB
Makefile
Raw Normal View History

2024-11-11 19:32:06 +00:00
LOCAL_BIN := $(CURDIR)/bin
PATH := $(LOCAL_BIN):$(PATH)
GO_IMAGE_VER := 1.23.3
ifeq (local-migrations-create,$(firstword $(MAKECMDGOALS)))
migrationName := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(migrationName):;@:)
endif
local-migrate-up:
@goose -allow-missing -dir ./migrations postgres "user=crab dbname=smm-core host=localhost port=5432 sslmode=disable" up
local-migrations-create:
@goose -dir ./migrations postgres "user=crab dbname=smm-core host=localhost port=5432 sslmode=disable" create "${migrationName}" sql
local-init-arm: local-init-common
@if [ ! -f Dockerfile ]; then \
echo "Creating Dockerfile file..."; \
echo "FROM golang:1.23.3-alpine3.19 as builder" >> Dockerfile; \
echo "WORKDIR /app" >> Dockerfile; \
echo "COPY . ." >> Dockerfile; \
echo "ENV GOOS=linux" >> Dockerfile; \
echo "ENV GOARCH=arm" >> Dockerfile; \
echo "RUN go build -o smm_tg cmd/smm_tg/main.go" >> Dockerfile; \
echo "FROM alpine:3.19" >> Dockerfile; \
echo "COPY --from=builder /app/smm_tg /usr/local/bin/smm_tg" >> Dockerfile; \
echo "RUN chmod +x /usr/local/bin/smm_tg" >> Dockerfile; \
echo "CMD [\"smm_tg\"]" >> Dockerfile; \
echo "Dockerfile file created"; \
else \
echo "Dockerfile file already exists"; \
fi
local-init-amd64: local-init-common
local-init-common:
@if [ ! -f .env ]; then \
echo "Creating .env file..."; \
echo "BOT_TOKEN=" >> .env; \
echo "POSTGRES_URL_CONNECT=" >> .env; \
echo ".env file created"; \
else \
echo ".env file already exists"; \
fi
@if [ ! -f docker-compose.yml ]; then \
echo "Creating docker-compose.yml file..."; \
cp build/ci/docker-compose.yml .; \
echo "docker-compose.yml file created"; \
else \
echo "docker-compose.yml file already exists"; \
fi