diff --git a/.air/.air.productapp.toml b/.air/.air.productapp.toml new file mode 100644 index 00000000..664dc09f --- /dev/null +++ b/.air/.air.productapp.toml @@ -0,0 +1,34 @@ +root = "." +tmp_dir = "cmd/productapp/temp" + +[build] + bin = "/entrypoint.sh" + args_bin = [] + cmd = "go build -mod=mod -buildvcs=false -o ./cmd/productapp/temp/main ./cmd/productapp/" + delay = 1000 + exclude_dir = ["vendor", "cmd/productapp/temp"] + exclude_file = [] + exclude_regex = [] + exclude_unchanged = false + follow_symlink = false + include_dir = [] + include_ext = ["go"] + kill_delay = "0s" + log = "build-errors.log" + send_interrupt = false + stop_on_error = true + poll = true + poll_interval = 1000 + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + time = false + +[misc] + clean_on_exit = false diff --git a/Makefile b/Makefile index f7c5f30f..6e126190 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ confirm: # ==================================================================================== # Productapp Service Commands # ==================================================================================== -.PHONY: productapp-up productapp-up-logs +.PHONY: productapp-up productapp-up-logs productapp-rebuild productapp-watch PRODUCTAPP_ENV = deploy/productapp/development/.env PRODUCTAPP_COMPOSE = deploy/productapp/development/docker-compose.yml @@ -91,6 +91,11 @@ productapp-up: docker compose --env-file $(PRODUCTAPP_ENV) -f $(PRODUCTAPP_COMPOSE) up --build -d @echo "productapp stack is up." +productapp-down: + @echo "Building and starting productapp full stack..." + docker compose --env-file $(PRODUCTAPP_ENV) -f $(PRODUCTAPP_COMPOSE) down + @echo "productapp stack is up." + productapp-up-logs: @echo "Building and starting productapp full stack..." docker compose --env-file $(PRODUCTAPP_ENV) -f $(PRODUCTAPP_COMPOSE) up --build diff --git a/deploy/productapp/development/Dockerfile b/deploy/productapp/development/Dockerfile index bbcc42a4..2d7e236e 100644 --- a/deploy/productapp/development/Dockerfile +++ b/deploy/productapp/development/Dockerfile @@ -5,14 +5,15 @@ FROM ${GO_IMAGE_NAME}:${GO_IMAGE_VERSION} ENV GOPROXY=https://package-mirror.liara.ir/repository/go/ ENV GOSUMDB=off - - WORKDIR /home/app COPY go.mod go.sum ./ RUN go mod download -COPY . . -RUN go build -mod=mod -o /bin/productapp cmd/productapp/main.go +RUN go install github.com/air-verse/air@latest -CMD ["/bin/productapp", "serve"] \ No newline at end of file +RUN printf '#!/bin/sh\n./cmd/productapp/temp/main migrate --up\nexec ./cmd/productapp/temp/main serve\n' > /entrypoint.sh && chmod +x /entrypoint.sh + +COPY . . + +CMD ["air", "-c", "/home/app/.air/.air.productapp.toml"] \ No newline at end of file diff --git a/deploy/productapp/development/docker-compose.yml b/deploy/productapp/development/docker-compose.yml index eef94489..906b42e2 100644 --- a/deploy/productapp/development/docker-compose.yml +++ b/deploy/productapp/development/docker-compose.yml @@ -9,7 +9,8 @@ services: container_name: productapp-app ports: - "8080:8080" - command: /bin/sh -c "/bin/productapp migrate --up && /bin/productapp serve" + volumes: + - ../../..:/home/app environment: DB_HOST: productapp-mysql DB_USERNAME: root