diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8d736cd..1a4808f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,7 @@ on: release: types: [published] push: + branches: [dev] tags: - "*.*.*" @@ -14,10 +15,9 @@ env: jobs: build-linux: runs-on: ubuntu-latest - services: postgres: - image: postgres:14 + image: postgres env: POSTGRES_PASSWORD: password options: >- @@ -29,16 +29,11 @@ jobs: - 5432:5432 env: DATABASE_URL: postgresql://postgres:password@localhost:5432/3la-test - + steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup Database - run: | - cargo install sqlx-cli --features postgres - sqlx db setup - - name: Docker meta id: meta uses: docker/metadata-action@v4 @@ -72,11 +67,12 @@ jobs: profile: minimal toolchain: stable override: true - - name: Migrate database + - name: Setup database env: DATABASE_URL: postgres://postgres:password@localhost:5432/3la-test run: | - cargo install --version=0.2.0 sqlx-cli --no-default-features --features postgres + cargo install sqlx-cli --no-default-features --features native-tls,postgres + echo "Run db creation" sqlx database create - uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/gen-binaries.yml b/.github/workflows/gen-binaries.yml index b21ec55..0f4b9a5 100644 --- a/.github/workflows/gen-binaries.yml +++ b/.github/workflows/gen-binaries.yml @@ -3,10 +3,26 @@ name: Build and upload release binaries on: release: types: [published] + push: + branches: [dev] jobs: build-linux: runs-on: ubuntu-latest + services: + postgres: + image: postgres:14 + env: + POSTGRES_PASSWORD: password + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + env: + DATABASE_URL: postgresql://postgres:password@localhost:5432/3la-test steps: - uses: actions/checkout@v3 @@ -24,9 +40,20 @@ jobs: sudo tar -C /usr/local -xzf go1.19.5.linux-amd64.tar.gz fi export PATH=$PATH:/usr/local/go/bin + + - name: Setup Database + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/3la-test + run: | + cargo install sqlx-cli --no-default-features --features native-tls,postgres + echo "Run db creation" + sqlx database create + - name: Build release binary run: | + export DATABASE_URL=postgres://postgres:password@localhost:5432/3la-test cargo build --release + - name: Upload Ubuntu binary uses: actions/upload-release-asset@v1.0.2 env: diff --git a/Dockerfile b/Dockerfile index ff7e1d8..ba151f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,10 +18,11 @@ COPY . /graphcast-3la WORKDIR /graphcast-3la RUN sh install-golang.sh -ENV DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la -RUN echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la" > .env +ARG DATABASE_URL=postgresql://postgres:password@localhost:5432/3la-test +RUN echo "DATABASE_URL=postgresql://postgres:password@localhost:5432/3la-test" > .env ENV PATH=$PATH:/usr/local/go/bin +RUN cargo sqlx prepare --check RUN cargo build --release FROM alpine:3.17.3 as alpine