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 29, 2023
1 parent 572c95f commit 4512388
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
14 changes: 7 additions & 7 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 @@ -28,16 +28,16 @@ jobs:
ports:
- 5432:5432
env:
DATABASE_URL: postgresql://postgres:password@localhost:5432/3la-test

DATABASE_URL: postgresql://postgres:password@localhost/realworld_axum_sqlx
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Database
run: |
cargo install sqlx-cli --features postgres
sqlx db setup
run: |
cargo install sqlx-cli --features postgres
sqlx db setup
- name: Docker meta
id: meta
Expand Down
24 changes: 24 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,16 @@ 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
run: |
cargo install sqlx-cli --features postgres
sqlx db setup
- name: Build release binary
run: |
export DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la
cargo build --release
- name: Upload Ubuntu binary
uses: actions/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion 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
ARG DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la
RUN echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la" > .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 4512388

Please sign in to comment.