Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
with:
args: make compile

- run: make docker-build

- run: make -C demo test

- run: make start_dev_env
Expand Down
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=24.3
ARG DEBIAN_VERSION=bullseye-20210902-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"

FROM ${BUILDER_IMAGE} AS builder
LABEL maintainer="dev@vaxine.io"

RUN apt-get update -y && \
apt-get install -y build-essential git curl && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*

WORKDIR /app
COPY config /app/
COPY lib /app/
COPY mix.* /app/
COPY Makefile /app/

RUN make compile release

FROM ${RUNNER_IMAGE} AS runner_setup

RUN apt-get update -y && \
apt-get install -y libstdc++6 openssl libncurses5 locales && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

WORKDIR "/app"
RUN chown nobody /app

FROM runner_setup AS runner

## Vaxine configuration via environment variables
COPY --from=builder --chown=nobody:root /app/_build/prod/rel/electric ./

USER nobody
ENTRYPOINT /app/bin/electric start
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ compile:
mix deps.get
mix compile

release:
MIX_ENV="prod" mix release

tests:
mix test

Expand All @@ -19,3 +22,11 @@ start_dev_env:

stop_dev_env:
docker-compose -f ${DC_CONFIG} down

docker-build:
docker build -t electric:local-build .

docker-clean:
ifneq ($(docker images -q electric:local-build 2> /dev/null), "")
docker image rm -f electric:local-build
endif
4 changes: 4 additions & 0 deletions demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ vaxine:

clean:
rm -rf lux
rm -rf vaxine .pull

docker-attach-%:
docker-compose exec $* bash
17 changes: 16 additions & 1 deletion demo/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: '3.1'

services:
electric_vaxine:
vaxine:
# image: vaxine:local-build
# restart: always
environment:
Expand All @@ -24,6 +24,17 @@ services:
context: ./vaxine
dockerfile: Dockerfile.vaxine

electric:
privileged: true
volumes:
- ./electric.exs:/app/releases/0.1.0/runtime.exs:ro
depends_on:
- db_a
- db_b
build:
context: ../
dockerfile: Dockerfile

db_a:
image: postgres:13
# restart: always
Expand All @@ -41,6 +52,8 @@ services:
- -c
- config_file=/etc/postgresql.conf
privileged: true
healthcheck:
test: ["CMD-SHELL", "pg_isready -U electric"]

db_b:
image: postgres:13
Expand All @@ -59,3 +72,5 @@ services:
- -c
- config_file=/etc/postgresql.conf
privileged: true
healthcheck:
test: ["CMD-SHELL", "pg_isready -U electric"]
19 changes: 19 additions & 0 deletions demo/electric.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Config

config :electric, Electric.Replication,
producer: Broadway.DummyProducer,
pg_client: Electric.Replication.MockPostgresClient

config :electric, Electric.PostgresRepo,
hostname: "db_a",
port: 5432,
database: "electric",
username: "electric",
password: "password"

config :electric, Electric.PostgresRepo2,
hostname: "db_b",
port: 5432,
database: "electric",
username: "electric",
password: "password"