This commit is contained in:
Josh Чернов 2022-11-24 20:27:04 -06:00 committed by GitHub
commit 09c263a4c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 0 deletions

14
Dockerfile.dev Normal file
View file

@ -0,0 +1,14 @@
# Used by docker-compose.yml
FROM hexpm/elixir:1.12.0-erlang-24.0.1-debian-bullseye-20210902-slim
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential dialog apt-utils gpg-agent \
apt-transport-https software-properties-common git curl postgresql-client inotify-tools && \
mix local.hex --force && \
mix archive.install hex phx_new 1.6.7 --force && \
mix local.rebar --force && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /app
COPY . .
EXPOSE 4000
CMD /bin/sh -c "while sleep 1000; do :; done"

View file

@ -11,6 +11,30 @@ if System.get_env("PHX_SERVER") && System.get_env("RELEASE_NAME") do
config :live_beats, LiveBeatsWeb.Endpoint, server: true
end
# Used by Dockerfile.dev.
if System.get_env("DEV_CONTAINER") do
database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE
"""
replica_database_url =
System.get_env("REPLICA_DATABASE_URL") || database_url
config :live_beats, LiveBeats.Repo,
url: database_url,
show_sensitive_data_on_connection_error: true,
pool_size: 10
config :live_beats, LiveBeats.ReplicaRepo,
url: replica_database_url,
show_sensitive_data_on_connection_error: true,
pool_size: 10,
priv: "priv/repo"
end
if config_env() == :prod do
database_url =
System.get_env("DATABASE_URL") ||

36
docker-compose.yml Normal file
View file

@ -0,0 +1,36 @@
version: "3"
services:
web:
container_name: "live_beats_dev"
build:
context: .
dockerfile: Dockerfile.dev
environment:
# Review the readme on how to register a github oauth app.
LIVE_BEATS_GITHUB_CLIENT_ID: "FIX_ME"
LIVE_BEATS_GITHUB_CLIENT_SECRET: "FIX_ME"
DEV_CONTAINER: "true"
DATABASE_URL: "ecto://postgres:postgres@db/live_beats_dev"
MIX_ENV: dev
volumes:
- .:/app/:cached
depends_on:
- db
ports:
- "4000:4000"
command:
- ./run.sh
db:
container_name: "live_beats_data"
image: "postgres:14.2"
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.max=10000 -c pg_stat_statements.track=all
environment:
POSTGRES_DB: "live_beats_dev"
POSTGRES_HOST_AUTH_METHOD: "trust"
ports:
- "5432:5432"
volumes:
- data:/var/lib/postgresql/data
volumes:
data:
driver: local

9
run.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
set -e
mix deps.get
mix ecto.setup
mix phx.server