Skip to content

Commit

Permalink
Add docker and docker compose (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfarr committed Sep 18, 2023
1 parent e7c429b commit 9e1276a
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 13 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ jobs:
runs-on: ubuntu-latest

env:
AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST: "localhost"
AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT: "5432"
AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME: "username"
AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD: "password"
AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_TEST_DATABASE: "resonate_test"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST: "localhost"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT: "5432"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME: "username"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD: "password"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE: "resonate_test"

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: ${{ env.AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME }}
POSTGRES_PASSWORD: ${{ env.AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_TEST_DATABASE }}
POSTGRES_USER: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME }}
POSTGRES_PASSWORD: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE }}
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.21 AS builder

WORKDIR /app
COPY . .

RUN go build -o resonate .

FROM golang:1.21

WORKDIR /app
COPY --from=builder /app/resonate .

EXPOSE 8001
EXPOSE 50051

ENTRYPOINT ["./resonate"]
70 changes: 70 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: '3'
services:
resonate:
build: .
container_name: resonate
command:
- serve
- --aio-store-postgres-host
- postgres
- --aio-store-postgres-username
- username
- --aio-store-postgres-password
- password
- --aio-store-postgres-database
- resonate
volumes:
- ./resonate.yml:/root/resonate.yml
ports:
- "8001:8001"
- "50051:50051"
depends_on:
- postgres
postgres:
image: postgres:15
container_name: postgres
environment:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
POSTGRES_DB: resonate
ports:
- "5432:5432"
read_only: true
tmpfs: /var/run/postgresql:rw,nosuid,nodev,noexec,mode=1777
security_opt:
- no-new-privileges:true

# dst
resonate-dst:
build: .
profiles: ["dst"]
container_name: resonate-dst
command:
- dst
- run
- --ticks
- "1"
- --aio-store-postgres-host
- postgres-dst
- --aio-store-postgres-username
- username
- --aio-store-postgres-password
- password
- --aio-store-postgres-database
- resonate_dst
volumes:
- ./resonate.yml:/root/resonate.yml
depends_on:
- postgres-dst
postgres-dst:
image: postgres:15
profiles: ["dst"]
container_name: postgres-dst
environment:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
POSTGRES_DB: resonate_dst
read_only: true
tmpfs: /var/run/postgresql:rw,nosuid,nodev,noexec,mode=1777
security_opt:
- no-new-privileges:true
10 changes: 5 additions & 5 deletions internal/app/subsystems/aio/store/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

func TestPostgresStore(t *testing.T) {
for _, tc := range test.TestCases {
host := withDefault("AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST", "")
port := withDefault("AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT", "localhost")
username := withDefault("AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME", "username")
password := withDefault("AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD", "password")
database := withDefault("AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_TEST_DATABASE", "resonate_test")
host := withDefault("TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST", "")
port := withDefault("TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT", "localhost")
username := withDefault("TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME", "username")
password := withDefault("TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD", "password")
database := withDefault("TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE", "resonate_test")

if host == "" {
t.Skip("Postgres is not configured, skipping")
Expand Down

0 comments on commit 9e1276a

Please sign in to comment.