Skip to content

Commit

Permalink
chores: docker and binary workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Jun 30, 2023
1 parent 572c95f commit 7a81deb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
release:
types: [published]
push:
branches: [dev]
tags:
- "*.*.*"

Expand All @@ -14,10 +15,9 @@ env:
jobs:
build-linux:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:14
image: postgres
env:
POSTGRES_PASSWORD: password
options: >-
Expand All @@ -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
Expand Down Expand Up @@ -72,11 +67,11 @@ 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 postgres,runtime-tokio-native-tls
sqlx database create
- uses: actions-rs/cargo@v1
with:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/gen-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,8 +40,18 @@ 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 postgres,runtime-tokio-native-tls
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/[email protected]
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a81deb

Please sign in to comment.