diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..2f44ebd --- /dev/null +++ b/.air.toml @@ -0,0 +1,22 @@ +# Docs for .air.toml +# https://github.com/cosmtrek/air/blob/master/air_example.toml + +root = "." + +[build] +cmd = "task build" +full_bin = "task serve" +delay = 100 +exclude_dir = ["tmp", "dist", "internal/database/dbgen"] +exclude_regex = [ + "_test.go", + "_generated.go", + ".sql.go", + ".gen.go", + ".min.js", + ".min.css", +] +include_ext = ["go", "sql", "js", "css", "json"] + +[log] +main_only = true diff --git a/docker/Dockerfile b/docker/Dockerfile index 2672714..9ecfd63 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,8 +25,7 @@ RUN apt update && apt install -y postgresql-common=248 && \ # Install system dependencies and PostgreSQL clients RUN apt update && \ apt install -y \ - wget=1.21.3-1+b2 unzip=6.0-28 git=1:2.39.2-1.1 \ - tzdata=2024a-0+deb12u1 lsof=4.95.0-1 \ + wget=1.21.3-1+b2 unzip=6.0-28 tzdata=2024a-0+deb12u1 \ postgresql-client-13 postgresql-client-14 \ postgresql-client-15 postgresql-client-16 && \ rm -rf /var/lib/apt/lists/* @@ -38,29 +37,29 @@ RUN \ tar -xzf task_linux_amd64.tar.gz && \ mv ./task /usr/local/bin/task && \ chmod +x /usr/local/bin/task && \ - \ - # Install GitHub CLI - wget --no-verbose https://github.com/cli/cli/releases/download/v2.55.0/gh_2.55.0_linux_amd64.tar.gz && \ - tar -xzf gh_2.55.0_linux_amd64.tar.gz && \ - mv gh_2.55.0_linux_amd64/bin/gh /usr/local/bin/gh && \ - chmod +x /usr/local/bin/gh && \ - \ + # Install goose wget --no-verbose https://github.com/pressly/goose/releases/download/v3.22.0/goose_linux_x86_64 && \ mv ./goose_linux_x86_64 /usr/local/bin/goose && \ chmod +x /usr/local/bin/goose && \ - \ + # Install sqlc wget --no-verbose https://github.com/sqlc-dev/sqlc/releases/download/v1.27.0/sqlc_1.27.0_linux_amd64.tar.gz && \ tar -xzf sqlc_1.27.0_linux_amd64.tar.gz && \ mv ./sqlc /usr/local/bin/sqlc && \ chmod +x /usr/local/bin/sqlc && \ - \ + # Install golangci-lint wget --no-verbose https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-amd64.tar.gz && \ tar -xzf golangci-lint-1.60.3-linux-amd64.tar.gz && \ mv ./golangci-lint-1.60.3-linux-amd64/golangci-lint /usr/local/bin/golangci-lint && \ - chmod +x /usr/local/bin/golangci-lint + chmod +x /usr/local/bin/golangci-lint && \ + + # Install air + wget --no-verbose https://github.com/cosmtrek/air/releases/download/v1.52.3/air_1.52.3_linux_amd64.tar.gz && \ + tar -xzf air_1.52.3_linux_amd64.tar.gz && \ + mv ./air /usr/local/bin/air && \ + chmod +x /usr/local/bin/air # Go to the app dir, delete the temporary dir and create backups dir WORKDIR /app diff --git a/docker/Dockerfile.cicd b/docker/Dockerfile.cicd index 7715b0f..c09be03 100644 --- a/docker/Dockerfile.cicd +++ b/docker/Dockerfile.cicd @@ -25,8 +25,7 @@ RUN apt update && apt install -y postgresql-common=248 && \ # Install system dependencies and PostgreSQL clients RUN apt update && \ apt install -y \ - wget=1.21.3-1+b2 unzip=6.0-28 git=1:2.39.2-1.1 \ - tzdata=2024a-0+deb12u1 lsof=4.95.0-1 \ + wget=1.21.3-1+b2 unzip=6.0-28 tzdata=2024a-0+deb12u1 \ postgresql-client-13 postgresql-client-14 \ postgresql-client-15 postgresql-client-16 && \ rm -rf /var/lib/apt/lists/* @@ -38,29 +37,29 @@ RUN \ tar -xzf task_linux_amd64.tar.gz && \ mv ./task /usr/local/bin/task && \ chmod +x /usr/local/bin/task && \ - \ - # Install GitHub CLI - wget --no-verbose https://github.com/cli/cli/releases/download/v2.55.0/gh_2.55.0_linux_amd64.tar.gz && \ - tar -xzf gh_2.55.0_linux_amd64.tar.gz && \ - mv gh_2.55.0_linux_amd64/bin/gh /usr/local/bin/gh && \ - chmod +x /usr/local/bin/gh && \ - \ + # Install goose wget --no-verbose https://github.com/pressly/goose/releases/download/v3.22.0/goose_linux_x86_64 && \ mv ./goose_linux_x86_64 /usr/local/bin/goose && \ chmod +x /usr/local/bin/goose && \ - \ + # Install sqlc wget --no-verbose https://github.com/sqlc-dev/sqlc/releases/download/v1.27.0/sqlc_1.27.0_linux_amd64.tar.gz && \ tar -xzf sqlc_1.27.0_linux_amd64.tar.gz && \ mv ./sqlc /usr/local/bin/sqlc && \ chmod +x /usr/local/bin/sqlc && \ - \ + # Install golangci-lint wget --no-verbose https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-amd64.tar.gz && \ tar -xzf golangci-lint-1.60.3-linux-amd64.tar.gz && \ mv ./golangci-lint-1.60.3-linux-amd64/golangci-lint /usr/local/bin/golangci-lint && \ - chmod +x /usr/local/bin/golangci-lint + chmod +x /usr/local/bin/golangci-lint && \ + + # Install air + wget --no-verbose https://github.com/cosmtrek/air/releases/download/v1.52.3/air_1.52.3_linux_amd64.tar.gz && \ + tar -xzf air_1.52.3_linux_amd64.tar.gz && \ + mv ./air /usr/local/bin/air && \ + chmod +x /usr/local/bin/air # Go to the app dir, delete the temporary dir and create backups dir WORKDIR /app diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index f360476..4641804 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -25,8 +25,7 @@ RUN apt update && apt install -y postgresql-common=248 && \ # Install system dependencies and PostgreSQL clients RUN apt update && \ apt install -y \ - wget=1.21.3-1+b2 unzip=6.0-28 git=1:2.39.2-1.1 \ - tzdata=2024a-0+deb12u1 lsof=4.95.0-1 \ + wget=1.21.3-1+b2 unzip=6.0-28 tzdata=2024a-0+deb12u1 \ postgresql-client-13 postgresql-client-14 \ postgresql-client-15 postgresql-client-16 && \ rm -rf /var/lib/apt/lists/* @@ -38,29 +37,29 @@ RUN \ tar -xzf task_linux_amd64.tar.gz && \ mv ./task /usr/local/bin/task && \ chmod +x /usr/local/bin/task && \ - \ - # Install GitHub CLI - wget --no-verbose https://github.com/cli/cli/releases/download/v2.55.0/gh_2.55.0_linux_amd64.tar.gz && \ - tar -xzf gh_2.55.0_linux_amd64.tar.gz && \ - mv gh_2.55.0_linux_amd64/bin/gh /usr/local/bin/gh && \ - chmod +x /usr/local/bin/gh && \ - \ + # Install goose wget --no-verbose https://github.com/pressly/goose/releases/download/v3.22.0/goose_linux_x86_64 && \ mv ./goose_linux_x86_64 /usr/local/bin/goose && \ chmod +x /usr/local/bin/goose && \ - \ + # Install sqlc wget --no-verbose https://github.com/sqlc-dev/sqlc/releases/download/v1.27.0/sqlc_1.27.0_linux_amd64.tar.gz && \ tar -xzf sqlc_1.27.0_linux_amd64.tar.gz && \ mv ./sqlc /usr/local/bin/sqlc && \ chmod +x /usr/local/bin/sqlc && \ - \ + # Install golangci-lint wget --no-verbose https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-amd64.tar.gz && \ tar -xzf golangci-lint-1.60.3-linux-amd64.tar.gz && \ mv ./golangci-lint-1.60.3-linux-amd64/golangci-lint /usr/local/bin/golangci-lint && \ - chmod +x /usr/local/bin/golangci-lint + chmod +x /usr/local/bin/golangci-lint && \ + + # Install air + wget --no-verbose https://github.com/cosmtrek/air/releases/download/v1.52.3/air_1.52.3_linux_amd64.tar.gz && \ + tar -xzf air_1.52.3_linux_amd64.tar.gz && \ + mv ./air /usr/local/bin/air && \ + chmod +x /usr/local/bin/air # Go to the app dir, delete the temporary dir and create backups dir WORKDIR /app diff --git a/package-lock.json b/package-lock.json index f2091ac..ad806d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "devDependencies": { "daisyui": "4.12.10", "esbuild": "0.23.1", - "kill-port": "^2.0.1", "standard": "17.1.0", "tailwindcss": "3.4.6" } @@ -2409,13 +2408,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-them-args": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/get-them-args/-/get-them-args-1.3.2.tgz", - "integrity": "sha512-LRn8Jlk+DwZE4GTlDbT3Hikd1wSHgLMme/+7ddlqKd7ldwR6LjJgTVWzBnR01wnYGe4KgrXjg287RaI22UHmAw==", - "dev": true, - "license": "MIT" - }, "node_modules/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", @@ -3152,20 +3144,6 @@ "json-buffer": "3.0.1" } }, - "node_modules/kill-port": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/kill-port/-/kill-port-2.0.1.tgz", - "integrity": "sha512-e0SVOV5jFo0mx8r7bS29maVWp17qGqLBZ5ricNSajON6//kmb7qqqNnml4twNE8Dtj97UQD+gNFOaipS/q1zzQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "get-them-args": "1.3.2", - "shell-exec": "1.0.2" - }, - "bin": { - "kill-port": "cli.js" - } - }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -4253,13 +4231,6 @@ "node": ">=8" } }, - "node_modules/shell-exec": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shell-exec/-/shell-exec-1.0.2.tgz", - "integrity": "sha512-jyVd+kU2X+mWKMmGhx4fpWbPsjvD53k9ivqetutVW/BQ+WIZoDoP4d8vUMGezV6saZsiNoW2f9GIhg9Dondohg==", - "dev": true, - "license": "MIT" - }, "node_modules/side-channel": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", diff --git a/package.json b/package.json index a13c7b3..e6d0fe6 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,11 @@ "scripts": { "tailwindcss": "tailwindcss", "standard": "standard", - "kill-port": "kill-port", "esbuild": "esbuild" }, "devDependencies": { "daisyui": "4.12.10", "esbuild": "0.23.1", - "kill-port": "2.0.1", "standard": "17.1.0", "tailwindcss": "3.4.6" }, diff --git a/taskfile.yaml b/taskfile.yaml index 9c0af55..8b65162 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -1,7 +1,5 @@ version: "3" -interval: 500ms - dotenv: [".env"] tasks: @@ -17,27 +15,7 @@ tasks: dev: desc: Build and serve the project with hot reloading - watch: true - sources: - - "**/*.go" - - "**/*.sql" - - "**/*.js" - - "**/*.css" - - "**/*.json" - - ".env" - - exclude: "tmp/**" - - exclude: "dist/**" - - exclude: "internal/database/dbgen/**" - - exclude: "internal/view/static/css/style.min.css" - - exclude: "internal/view/static/js/app.min.js" - - exclude: "**/*.gen.go" - - exclude: "**/*.sql.go" - - exclude: "**/*_test.go" - - exclude: "**/_generated.go" - cmds: - - npm run kill-port -- 8085 - - task build - - task serve + cmd: air -c .air.toml build: desc: Build the project