From bfa4222ce8948d5abaea8cb98a6c417dea727e7b Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Sat, 7 Dec 2024 12:22:38 +0200 Subject: [PATCH 1/8] ci: add gen deploy --- .github/workflows/loco-gen-deploy.yml | 62 +++++++++++++++++++++++++++ loco-gen/src/lib.rs | 1 + 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/loco-gen-deploy.yml diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml new file mode 100644 index 000000000..8b8654311 --- /dev/null +++ b/.github/workflows/loco-gen-deploy.yml @@ -0,0 +1,62 @@ +name: "[loco-gen-deploy]" + +on: + push: + branches: + - master + pull_request: + +env: + RUST_TOOLCHAIN: stable + TOOLCHAIN_PROFILE: minimal + +jobs: + test: + runs-on: ubuntu-latest + + permissions: + contents: read + + services: + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - "6379:6379" + postgres: + image: postgres + env: + POSTGRES_DB: postgres_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - "5432:5432" + # Set health checks to wait until postgres has started + options: --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install seaorm cli + run: cargo install sea-orm-cli + + - name: + run: cargo run -- generate deployment && docker build -t demo . + working-directory: ./examples/demo + env: + LOCO_DEPLOYMENT_KIND: docker + REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 90ed56a93..21e43e334 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -134,6 +134,7 @@ impl FromStr for DeploymentKind { match s.to_lowercase().as_str() { "docker" => Ok(Self::Docker), "shuttle" => Ok(Self::Shuttle), + "ngnix" => Ok(Self::Nginx), _ => Err(()), } } From 3309e06cce422ef04921889b3ac084a0ccf13b8e Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Sat, 7 Dec 2024 13:00:17 +0200 Subject: [PATCH 2/8] ci: add gen deploy --- .github/workflows/loco-gen-deploy.yml | 38 +++++++-------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml index 8b8654311..48dfe5c35 100644 --- a/.github/workflows/loco-gen-deploy.yml +++ b/.github/workflows/loco-gen-deploy.yml @@ -17,30 +17,6 @@ jobs: permissions: contents: read - services: - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - "6379:6379" - postgres: - image: postgres - env: - POSTGRES_DB: postgres_test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - # Set health checks to wait until postgres has started - options: --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - name: Checkout the code uses: actions/checkout@v4 @@ -53,10 +29,16 @@ jobs: - name: Install seaorm cli run: cargo install sea-orm-cli + - name: install 'loco new' + run: | + cargo install --path ./loco-new + + - name: install 'loco new' + run: | + loco new -n myapp --db sqlite --bg async --assets serverside -a + - name: - run: cargo run -- generate deployment && docker build -t demo . - working-directory: ./examples/demo + run: cargo loco generate deployment && docker build -t demo . + working-directory: ./myapp env: LOCO_DEPLOYMENT_KIND: docker - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test From a80672e28c3764563c3f3d3ccd87c5f25386e707 Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Sat, 7 Dec 2024 13:21:21 +0200 Subject: [PATCH 3/8] ci: add gen deploy --- .github/workflows/loco-gen-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml index 48dfe5c35..839ccf72f 100644 --- a/.github/workflows/loco-gen-deploy.yml +++ b/.github/workflows/loco-gen-deploy.yml @@ -31,9 +31,9 @@ jobs: - name: install 'loco new' run: | - cargo install --path ./loco-new + cargo install loco - - name: install 'loco new' + - name: create myapp run: | loco new -n myapp --db sqlite --bg async --assets serverside -a From ca8ef28bd0a130acb6d4826cffa23058e1831317 Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Sun, 8 Dec 2024 01:30:05 +0200 Subject: [PATCH 4/8] ci: add gen deploy --- loco-gen/src/templates/deployment/docker/docker.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loco-gen/src/templates/deployment/docker/docker.t b/loco-gen/src/templates/deployment/docker/docker.t index 8dcbfa877..1071b5771 100644 --- a/loco-gen/src/templates/deployment/docker/docker.t +++ b/loco-gen/src/templates/deployment/docker/docker.t @@ -2,7 +2,7 @@ to: "dockerfile" skip_exists: true message: "Dockerfile generated successfully." --- -FROM rust:1.74-slim as builder +FROM rust:1.83-slim as builder WORKDIR /usr/src/ @@ -23,4 +23,4 @@ COPY --from=builder /usr/src/{{fallback_file}} /usr/app/{{fallback_file}} COPY --from=builder /usr/src/config /usr/app/config COPY --from=builder /usr/src/target/release/{{pkg_name}}-cli /usr/app/{{pkg_name}}-cli -ENTRYPOINT ["/usr/app/{{pkg_name}}-cli"] \ No newline at end of file +ENTRYPOINT ["/usr/app/{{pkg_name}}-cli"] From c411df22b77235cfcf0a8f4456c8a33fb4768d33 Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Sun, 8 Dec 2024 01:40:27 +0200 Subject: [PATCH 5/8] ci: add gen deploy --- .github/workflows/loco-gen-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml index 839ccf72f..45c80c2a3 100644 --- a/.github/workflows/loco-gen-deploy.yml +++ b/.github/workflows/loco-gen-deploy.yml @@ -11,7 +11,7 @@ env: TOOLCHAIN_PROFILE: minimal jobs: - test: + g-deploy-docker: runs-on: ubuntu-latest permissions: @@ -31,7 +31,7 @@ jobs: - name: install 'loco new' run: | - cargo install loco + cargo install --path ../loco-new - name: create myapp run: | From a30c644e597b4a797737d30a793550adb69234e6 Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Sun, 8 Dec 2024 01:51:59 +0200 Subject: [PATCH 6/8] ci: add gen deploy --- .github/workflows/loco-gen-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml index 45c80c2a3..7f7821199 100644 --- a/.github/workflows/loco-gen-deploy.yml +++ b/.github/workflows/loco-gen-deploy.yml @@ -31,7 +31,7 @@ jobs: - name: install 'loco new' run: | - cargo install --path ../loco-new + cargo install --path ./loco-new - name: create myapp run: | From 53e7ab9a902089f4fd500f5618cd511c459b2fc0 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 12 Jan 2025 10:10:46 +0200 Subject: [PATCH 7/8] fix command --- .github/workflows/loco-gen-deploy.yml | 5 ++--- src/cli.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml index 7f7821199..81eb24692 100644 --- a/.github/workflows/loco-gen-deploy.yml +++ b/.github/workflows/loco-gen-deploy.yml @@ -38,7 +38,6 @@ jobs: loco new -n myapp --db sqlite --bg async --assets serverside -a - name: - run: cargo loco generate deployment && docker build -t demo . + run: cargo loco generate deployment docker && docker build -t demo . working-directory: ./myapp - env: - LOCO_DEPLOYMENT_KIND: docker + diff --git a/src/cli.rs b/src/cli.rs index 63b68a755..b3f280568 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -327,7 +327,7 @@ After running the migration, follow these steps to complete the process: /// Generate a deployment infrastructure Deployment { // deployment kind. - #[clap(long, value_enum)] + #[clap(value_enum)] kind: DeploymentKind, }, From 9741f66c4c2f9709287c71cb59ae44a6d757c007 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 12 Jan 2025 10:22:03 +0200 Subject: [PATCH 8/8] flag --- .github/workflows/loco-gen-deploy.yml | 2 +- src/cli.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/loco-gen-deploy.yml b/.github/workflows/loco-gen-deploy.yml index 81eb24692..f2ebdd754 100644 --- a/.github/workflows/loco-gen-deploy.yml +++ b/.github/workflows/loco-gen-deploy.yml @@ -38,6 +38,6 @@ jobs: loco new -n myapp --db sqlite --bg async --assets serverside -a - name: - run: cargo loco generate deployment docker && docker build -t demo . + run: cargo loco generate deployment --kind docker && docker build -t demo . working-directory: ./myapp diff --git a/src/cli.rs b/src/cli.rs index b3f280568..63b68a755 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -327,7 +327,7 @@ After running the migration, follow these steps to complete the process: /// Generate a deployment infrastructure Deployment { // deployment kind. - #[clap(value_enum)] + #[clap(long, value_enum)] kind: DeploymentKind, },