This commit is contained in:
Michael
2026-04-29 20:11:57 +02:00
commit a14103ad8e
167 changed files with 7060 additions and 0 deletions

37
.dev/.mk/develop.mk Normal file
View File

@ -0,0 +1,37 @@
##@ Develop:
.PHONY: app
app: ## start shell in qrcode
docker compose exec qrcode-app sh
app-root: ## start shell in qrcode
docker compose exec -u root qrcode-app sh
app-run: ## start shell in qrcode
docker compose run qrcode-app sh
front: ## start frontend in ssr
docker compose exec qrcode-front sh
front-run: ## start frontend in ssr
docker compose run qrcode-front sh
sql: ## start shell in qrcode
docker compose exec qrcode-postgres bash
app-tidy:
docker compose exec qrcode-app sh -c "go mod tidy"
app-vendor:
docker compose exec qrcode-app sh -c "go mod vendor"
db-exec: ## start db
docker compose exec qrcode-postgres bash
web:
docker compose exec qrcode-web sh
swager:
docker compose exec qrcode-app sh -c "swag init -g ./cmd/server.go -o ./docs --parseInternal --parseDependency"
minio:
docker compose exec qrcode-minio sh

26
.dev/.mk/help/mark.mk Normal file
View File

@ -0,0 +1,26 @@
# Color font
<cWhite> = \033[30m
<cRed> = \033[31m
<cGreen> = \033[32m
<cYellow> = \033[33m
<cBlue> = \033[34m
<cPurple> = \033[35m
<cTurquoise> = \033[36m
<cGray> = \033[37m
# Select
<sWhite> = \033[40m
<sRed> = \033[41m
<sGreen> = \033[42m
<sYellow> = \033[43m
<sBlue> = \033[44m
<sPurple> = \033[45m
<sTurquoise> = \033[46m
<sGray> = \033[47m
# Emphasis (typography)
<b> = \033[1m
<u> = \033[4m
</> = \033[0m
<br> = \n

11
.dev/.mk/help/msg.mk Normal file
View File

@ -0,0 +1,11 @@
.PHONY: help
help: help_message
help_message:
@awk 'BEGIN {FS = ":.*##"; \
printf "$(<b>)$(<cYellow>)Usage:$(</>)$(</>) \
$(<br>)make $(<cGreen>)<target>$(</>) $(<cBlue>)\"<arguments>\"$(</>)\
$(<br>)$(<br>)$(<b>)$(<cYellow>)Available commands:$(</>)$(</>) \
$(<br>)"}/^[a-zA-Z_-]+:.*?##/{ printf " $(<cGreen>)%-10s$(</>) %s$(<br>)", $$1, $$2 } /^##@/{ printf "\
$(<br>)$(<b>)%s$(</>)$(<br>)", substr($$0, 5) }'$(MAKEFILE_LIST)

14
.dev/.mk/migratioin.mk Normal file
View File

@ -0,0 +1,14 @@
migrate-up: ## Migrate seo db to the most recent version available
docker compose exec qrcode-app sh -c 'goose -dir ./migrations postgres "host=qrcode-postgres port=5432 user=admin password=admin dbname=qrcode sslmode=disable" up'
migrate-down:
docker compose exec qrcode-app sh -c 'goose -dir ./migrations postgres "host=qrcode-postgres port=5432 user=admin password=admin dbname=qrcode sslmode=disable" down'
migrate-reset:
docker compose exec qrcode-app sh -c 'goose -dir ./migrations postgres "host=qrcode-postgres port=5432 user=admin password=admin dbname=qrcode sslmode=disable" reset'
migrate-status:
docker compose exec qrcode-app sh -c 'goose -dir ./migrations postgres "host=qrcode-postgres port=5432 user=admin password=admin dbname=qrcode sslmode=disable" status'
migrate-create:
docker compose exec qrcode-app sh -c 'goose -dir ./migrations create ${ARGS} sql'

40
.dev/.mk/system.mk Normal file
View File

@ -0,0 +1,40 @@
##@ System:
build: ## build project
docker compose build
build-no-cache: ## build project
docker compose build --no-cache
install: ## install the project
docker compose up -d
echo "waiting db up..."
sleep 5
echo "migrate db"
docker compose exec qrcode-app sh -c 'goose -dir ./migrations postgres "host=qrcode-postgres port=5432 user=admin password=admin dbname=qrcode sslmode=disable" up'
echo "install go requarements"
docker compose exec qrcode-app sh -c "go mod tidy"
docker compose exec qrcode-app sh -c "go mod vendor"
echo "install nodejs requarements"
docker compose run qrcode-front sh -c 'npm install'
docker compose stop
echo "start the project"
docker compose up --remove-orphans
up: ## start project
docker compose up -d --remove-orphans
stop: ## stop project
docker compose stop
down: ## stop project (remove db. Need to make migrate-up)
docker compose down
watch: ## watch project
docker compose up --remove-orphans
state: ## show state
docker compose ps
logs: ## show last 100 lines of logs
docker compose logs --tail=100 $(ARGS)

22
.dev/.mk/test.mk Normal file
View File

@ -0,0 +1,22 @@
##@ Test
DOCKER_COMPOSE := docker compose
APP_SERVICE := qrcode-app
GO_TEST := $(DOCKER_COMPOSE) exec $(APP_SERVICE) sh -c
COVERAGE_FILE := ./tmp/coverage.out
EXCLUDE := /internal/view|/vendor|/migrations|/tmp|/build
.PHONY: test race cover
test: ## Run tests excluding some directories
$(GO_TEST) 'go test -v -count=1 $$(go list ./... | grep -vE "$(EXCLUDE)") | grep -v "\[no test files\]"'
race: ## Run tests with race detector
$(GO_TEST) 'go test -v -race -count=1 ./...'
cover: ## Run tests with coverage and save HTML report
$(GO_TEST) 'mkdir -p ./tmp && \
go test -v -short -coverprofile=$(COVERAGE_FILE) ./... && \
go tool cover -html=$(COVERAGE_FILE) -o ./tmp/coverage.html && \
rm -f $(COVERAGE_FILE)'

39
.dev/app/Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM golang:1.26.1-alpine3.23
RUN apk update && apk upgrade && apk add --no-cache curl libwebp-dev alpine-sdk vips-dev git
ARG UID=1000
ARG GID=1000
ARG HOME=/home/app
ARG WORKDIR=/app
ENV USR=app
ENV GRP=app
ENV GOPATH=${HOME}/bin
ENV PATH=$PATH:$GOPATH:$GOPATH/bin
RUN addgroup --gid "${GID}" "${GRP}"
RUN adduser \
-S \
-u "${UID}" \
-g "${GID}" \
-D "${GRP}" \
-h /home/app \
"${USR}"
RUN mkdir ${WORKDIR}
RUN chown -R ${USR}:${GRP} ${WORKDIR}
USER ${USR}
WORKDIR ${WORKDIR}
RUN go install github.com/air-verse/air@v1.64.5
RUN go install github.com/swaggo/swag/cmd/swag@v1.16.6
RUN go install github.com/pressly/goose/v3/cmd/goose@v3.26.0
RUN export CGO_ENABLED=1
# RUN go install github.com/stripe/stripe-cli@latest
ENTRYPOINT air

17
.dev/front/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM node:lts-alpine3.23
RUN apk update && apk upgrade
ARG WORKDIR=/app
ARG APPDIR=${WORKDIR}
RUN mkdir -p ${APPDIR}
RUN chown -R node:node ${WORKDIR}
USER node
WORKDIR ${APPDIR}
# RUN npm run build
CMD [ "npm", "run", "dev" ]

5
.dev/nginx/Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM nginx:1.23-alpine
RUN apk update && apk upgrade && apk add --no-cache openssl
CMD ["nginx", "-g", "daemon off;"]

View File

@ -0,0 +1,43 @@
server {
listen 80;
root /app;
client_max_body_size 400M;
server_name _;
location /tmp/ {
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
}
location / {
proxy_pass http://qrcode-app:3000;
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
add_header Pragma "no-cache";
add_header Expires 0;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /public {
proxy_pass http://qrcode-front:3000;
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
add_header Pragma "no-cache";
add_header Expires 0;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}