Skip to content

Commit a19c774

Browse files
committed
chore: Create in-depth Docker dev environment w/ Scylla
1 parent dea344a commit a19c774

21 files changed

Lines changed: 314 additions & 28 deletions

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ erl_crash.dump
2525
# Docker volumes
2626
/pgdata
2727
/msg_pgdata
28-
/scylla_data
28+
/dev/scylla/data
2929

3030
# Ignore package tarball (built via "mix hex.build").
3131
octocon-*.tar

‎config/dev-template.exs‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import Config
22

3-
config :octocon, Octocon.MessageRepo,
4-
username: "postgres",
5-
password: "postgres",
6-
hostname: "localhost",
7-
database: "octocon_dev",
8-
port: "4002",
9-
stacktrace: true,
10-
show_sensitive_data_on_connection_error: true,
11-
pool_size: 10
12-
133
config :octocon, :primary_node_count, 1
144

155
# Discord channel scope
@@ -69,10 +59,31 @@ config :phoenix, :stacktrace_depth, 20
6959
# Initialize plugs at runtime for faster development compilation
7060
config :phoenix, :plug_init_mode, :runtime
7161

62+
config :octocon, Octocon.Repo,
63+
nodes: ["scylla-nam"],
64+
load_balancing:
65+
{Xandra.Cluster.LoadBalancingPolicy.DCAwareRoundRobin,
66+
[local_data_center: "nam"]},
67+
refresh_topology_interval: :timer.minutes(1),
68+
sync_connect: :infinity,
69+
pool_size: 10
70+
71+
config :octocon, Octocon.MessageRepo,
72+
username: "postgres",
73+
password: "postgres",
74+
hostname: "msg-db",
75+
database: "octocon_dev",
76+
port: "5432",
77+
stacktrace: true,
78+
show_sensitive_data_on_connection_error: true,
79+
pool_size: 10
80+
7281
# Discord token
7382
config :nostrum,
7483
token: "TODO"
7584

85+
config :octocon, :current_db_region, "nam"
86+
7687
# Discord auth
7788
config :ueberauth, Ueberauth.Strategy.Discord.OAuth,
7889
client_id: "TODO",
@@ -86,7 +97,9 @@ config :ueberauth, Ueberauth.Strategy.Google.OAuth,
8697
# Guardian
8798
config :octocon, Octocon.Auth.Guardian,
8899
issuer: "octocon",
89-
secret_key: "TODO"
100+
secret_key: "Vui-nVt36x8I-8EWN8Fg5xvv588aniMu5eubeD7ZTdwIBdwt4qHDVXyL-2NjAeE1"
101+
102+
config :octocon, :pepper, "6dtfTrHA"
90103

91104
config :waffle,
92105
storage: Waffle.Storage.S3,

‎dev/Dockerfile‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
ARG ELIXIR_VERSION=1.19.5
2+
ARG OTP_VERSION=27.0
3+
ARG DEBIAN_VERSION=trixie-20260112-slim
4+
5+
FROM "hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
6+
7+
ENV MIX_BUILD_ROOT=/build
8+
ENV MIX_DEPS_PATH=/deps
9+
ENV HOME=/home/user
10+
11+
RUN mkdir /build && \
12+
chown nobody /build && \
13+
mkdir /deps && \
14+
chown nobody /deps && \
15+
mkdir /docker && \
16+
chown nobody /docker && \
17+
mkdir /home/user && \
18+
chown nobody /home/user
19+
20+
ADD dev/docker /docker
21+
22+
RUN chmod +x /docker/entrypoint.sh /docker/command.sh && \
23+
chown nobody /docker/entrypoint.sh /docker/command.sh
24+
25+
RUN apt-get update -y && apt-get install -y build-essential git libstdc++6 openssl libncurses6 locales ca-certificates curl gnupg iproute2 iputils-ping jq \
26+
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
27+
28+
# Set the locale
29+
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
30+
31+
USER nobody
32+
33+
# install hex + rebar
34+
RUN mix local.hex --force && \
35+
mix local.rebar --force
36+
37+
ENV LANG="en_US.UTF-8"
38+
ENV LANGUAGE="en_US:en"
39+
ENV LC_ALL="en_US.UTF-8"
40+
41+
VOLUME /app
42+
VOLUME /build
43+
VOLUME /deps
44+
WORKDIR /app
45+
46+
EXPOSE 4000
47+
48+
CMD ["/docker/command.sh"]
49+
ENTRYPOINT ["/docker/entrypoint.sh"]

‎dev/bin/iex‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
docker compose -f docker-compose.dev.yml run --rm octocon-app iex -S mix phx.server

‎dev/bin/setup‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
docker compose -f docker-compose.dev.yml run --rm octocon-app mix setup
4+

‎dev/docker/command.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
# mix phx.server
5+
tail -f /dev/null

‎dev/docker/entrypoint.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
mix deps.get
5+
6+
"$@"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dc=eas
2+
rack=rack1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dc=eur
2+
rack=rack1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dc=gdpr
2+
rack=rack1

0 commit comments

Comments
 (0)