attempt to get phoenix dockerized
This commit is contained in:
parent
bb16921a74
commit
0e60ad1a86
|
@ -0,0 +1,2 @@
|
||||||
|
erlang 27.0.1
|
||||||
|
elixir 1.17.2
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Use an official Elixir runtime as a parent image.
|
||||||
|
FROM elixir:latest
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y postgresql-client inotify-tools nodejs npm
|
||||||
|
|
||||||
|
# Create app directory and copy the Elixir projects into it.
|
||||||
|
RUN mkdir /app
|
||||||
|
COPY . /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install Hex package manager.
|
||||||
|
RUN mix local.hex --force
|
||||||
|
|
||||||
|
# Compile the project.
|
||||||
|
RUN mix deps.get
|
||||||
|
|
||||||
|
WORKDIR /app/assets
|
||||||
|
RUN npm install --verbose
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
RUN mix assets.setup
|
||||||
|
RUN mix assets.build
|
||||||
|
RUN mix do compile
|
||||||
|
|
||||||
|
CMD ["/app/entrypoint.sh"]
|
|
@ -27,7 +27,7 @@ config :poex, Poex.Repo,
|
||||||
username: "postgres",
|
username: "postgres",
|
||||||
password: "postgres",
|
password: "postgres",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
port: 5560
|
port: 5432
|
||||||
|
|
||||||
# Configures the mailer
|
# Configures the mailer
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,8 +4,9 @@ import Config
|
||||||
config :poex, Poex.Repo,
|
config :poex, Poex.Repo,
|
||||||
username: "postgres",
|
username: "postgres",
|
||||||
password: "postgres",
|
password: "postgres",
|
||||||
hostname: "localhost",
|
hostname: System.get_env("PGHOST") || "localhost",
|
||||||
database: "poex_dev",
|
database: "poex_dev",
|
||||||
|
port: System.get_env("PGPORT") |> String.to_integer() || 5432,
|
||||||
stacktrace: true,
|
stacktrace: true,
|
||||||
show_sensitive_data_on_connection_error: true,
|
show_sensitive_data_on_connection_error: true,
|
||||||
pool_size: 10
|
pool_size: 10
|
||||||
|
|
|
@ -1,43 +1,36 @@
|
||||||
version: '3.9'
|
version: "3.9"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
phoenix:
|
||||||
|
# The build parameters for this container.
|
||||||
|
build:
|
||||||
|
# Here we define that it should build from the current directory.
|
||||||
|
context: .
|
||||||
|
environment:
|
||||||
|
# Variables to connect to our Postgres server.
|
||||||
|
PGUSER: postgres
|
||||||
|
PGPASSWORD: postgres
|
||||||
|
PGDATABASE: poex_dev
|
||||||
|
PGPORT: 5432
|
||||||
|
# Hostname of our Postgres container.
|
||||||
|
PGHOST: pg-master
|
||||||
|
ports:
|
||||||
|
# Mapping the port to make the Phoenix app accessible outside of the container.
|
||||||
|
- "4000:4000"
|
||||||
|
depends_on:
|
||||||
|
# The DB container needs to be started before we start this container.
|
||||||
|
- pg-master
|
||||||
|
|
||||||
pg-master:
|
pg-master:
|
||||||
image: kartoza/postgis:16-3.4
|
image: kartoza/postgis:16-3.4
|
||||||
restart: 'always'
|
restart: "always"
|
||||||
ports:
|
|
||||||
- '5560:5432'
|
|
||||||
environment:
|
environment:
|
||||||
ALLOW_IP_RANGE: '0.0.0.0/0'
|
POSTGRES_USER: "postgres"
|
||||||
REPLICATION_USER: 'replicator'
|
POSTGRES_PASS: "postgres"
|
||||||
REPLICATION_PASS: 'replicator'
|
|
||||||
REPLICATION: 'true'
|
|
||||||
POSTGRES_USER: 'postgres'
|
|
||||||
POSTGRES_PASS: 'postgres'
|
|
||||||
POSTGRES_MULTIPLE_EXTENSIONS: postgis
|
POSTGRES_MULTIPLE_EXTENSIONS: postgis
|
||||||
volumes:
|
volumes:
|
||||||
- pg-master:/var/lib/postgresql
|
- pg-master:/var/lib/postgresql
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: "exit 0"
|
test: "exit 0"
|
||||||
pg-replica1:
|
|
||||||
image: kartoza/postgis:16-3.4
|
|
||||||
restart: 'always'
|
|
||||||
ports:
|
|
||||||
- '5561:5432'
|
|
||||||
environment:
|
|
||||||
ALLOW_IP_RANGE: '0.0.0.0/0'
|
|
||||||
REPLICATION_USER: 'replicator'
|
|
||||||
REPLICATION_PASS: 'replicator'
|
|
||||||
REPLICATION: 'true'
|
|
||||||
POSTGRES_USER: 'postgres'
|
|
||||||
POSTGRES_PASS: 'postgres'
|
|
||||||
POSTGRES_MULTIPLE_EXTENSIONS: postgis
|
|
||||||
REPLICATE_FROM: pg-master
|
|
||||||
DESTROY_DATABASE_ON_RESTART: 'True'
|
|
||||||
volumes:
|
|
||||||
- pg-replica1:/var/lib/postgresql
|
|
||||||
depends_on:
|
|
||||||
pg-master:
|
|
||||||
condition: service_healthy
|
|
||||||
volumes:
|
volumes:
|
||||||
pg-master:
|
pg-master:
|
||||||
pg-replica1:
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Docker entrypoint script.
|
||||||
|
|
||||||
|
# Wait until Postgres is ready.
|
||||||
|
while ! pg_isready -q -h $PGHOST -p $PGPORT -U $PGUSER
|
||||||
|
do
|
||||||
|
echo "$(date) - waiting for database to start"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create, migrate, and seed database if it doesn't exist.
|
||||||
|
if [[ -z `psql -Atqc "\\list $PGDATABASE"` ]]; then
|
||||||
|
echo "Database $PGDATABASE does not exist. Creating..."
|
||||||
|
createdb -E UTF8 $PGDATABASE -l en_US.UTF-8 -T template0
|
||||||
|
mix setup
|
||||||
|
echo "Database $PGDATABASE created."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec mix phx.server
|
Loading…
Reference in New Issue