Add docker-compose dev
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
bb1cdc2043
commit
c4cfb081e7
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM elixir:1.6
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential inotify-tools postgresql-client
|
||||
|
||||
RUN mix local.hex --force && mix local.rebar --force
|
||||
|
||||
COPY docker/entrypoint.sh /bin/entrypoint
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
EXPOSE 4000
|
|
@ -47,15 +47,14 @@ config :logger, :console, format: "[$level] $message\n", level: :debug
|
|||
# in production as building large stacktraces may be expensive.
|
||||
config :phoenix, :stacktrace_depth, 20
|
||||
|
||||
config :eventos, Eventos.Mailer,
|
||||
adapter: Bamboo.LocalAdapter
|
||||
config :eventos, Eventos.Mailer, adapter: Bamboo.LocalAdapter
|
||||
|
||||
# Configure your database
|
||||
config :eventos, Eventos.Repo,
|
||||
adapter: Ecto.Adapters.Postgres,
|
||||
types: Eventos.PostgresTypes,
|
||||
username: "elixir",
|
||||
password: "elixir",
|
||||
database: "eventos_dev",
|
||||
hostname: "localhost",
|
||||
username: System.get_env("POSTGRES_USER") || "elixir",
|
||||
password: System.get_env("POSTGRES_PASSWORD") || "elixir",
|
||||
database: System.get_env("POSTGRES_DATABASE") || "eventos_dev",
|
||||
hostname: System.get_env("POSTGRES_HOST") || "localhost",
|
||||
pool_size: 10
|
||||
|
|
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
|
||||
postgres:
|
||||
container_name: eventos_db
|
||||
restart: unless-stopped
|
||||
image: mdillon/postgis:10
|
||||
environment:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: eventos_dev
|
||||
|
||||
front:
|
||||
container_name: eventos_front
|
||||
restart: unless-stopped
|
||||
build: ./js
|
||||
volumes:
|
||||
- './js:/app/js'
|
||||
ports:
|
||||
- "80:8080"
|
||||
entrypoint: entrypoint
|
||||
|
||||
api:
|
||||
container_name: eventos_api
|
||||
restart: unless-stopped
|
||||
build: .
|
||||
volumes:
|
||||
- '.:/app'
|
||||
ports:
|
||||
- "4000:4000"
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_DATABASE: eventos_dev
|
||||
POSTGRES_HOST: postgres
|
||||
entrypoint: entrypoint
|
22
docker/entrypoint.sh
Executable file
22
docker/entrypoint.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
mix deps.get
|
||||
|
||||
# Wait for Postgres to become available.
|
||||
until PGPASSWORD=$POSTGRES_PASSWORD psql -h postgres -U "postgres" -c '\q' 2>/dev/null; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "\nPostgres is available: continuing with database setup..."
|
||||
|
||||
# Potentially Set up the database
|
||||
mix ecto.create
|
||||
mix ecto.migrate
|
||||
|
||||
echo "\nTesting the installation..."
|
||||
# "Proove" that install was successful by running the tests
|
||||
mix test
|
||||
|
||||
echo "\n Launching Phoenix web server..."
|
||||
iex -S mix phx.server
|
9
js/Dockerfile
Normal file
9
js/Dockerfile
Normal file
|
@ -0,0 +1,9 @@
|
|||
FROM node:10
|
||||
|
||||
LABEL maintainer="tcit"
|
||||
|
||||
COPY docker/entrypoint.sh /bin/entrypoint
|
||||
|
||||
WORKDIR /app/js
|
||||
|
||||
EXPOSE 8080
|
5
js/docker/entrypoint.sh
Executable file
5
js/docker/entrypoint.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
npm install
|
||||
npm rebuild node-sass
|
||||
npm run serve
|
19
mix.exs
19
mix.exs
|
@ -6,13 +6,18 @@ defmodule Eventos.Mixfile do
|
|||
app: :eventos,
|
||||
version: "0.0.1",
|
||||
elixir: "~> 1.4",
|
||||
elixirc_paths: elixirc_paths(Mix.env),
|
||||
compilers: [:phoenix, :gettext] ++ Mix.compilers,
|
||||
start_permanent: Mix.env == :prod,
|
||||
elixirc_paths: elixirc_paths(Mix.env()),
|
||||
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
|
||||
start_permanent: Mix.env() == :prod,
|
||||
aliases: aliases(),
|
||||
deps: deps(),
|
||||
test_coverage: [tool: ExCoveralls],
|
||||
preferred_cli_env: ["coveralls": :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test],
|
||||
preferred_cli_env: [
|
||||
coveralls: :test,
|
||||
"coveralls.detail": :test,
|
||||
"coveralls.post": :test,
|
||||
"coveralls.html": :test
|
||||
],
|
||||
name: "Eventos",
|
||||
source_url: "https://framagit.org/tcit/eventos",
|
||||
homepage_url: "https://framagit.org/tcit/eventos",
|
||||
|
@ -32,7 +37,7 @@ defmodule Eventos.Mixfile do
|
|||
|
||||
# Specifies which paths to compile per environment.
|
||||
defp elixirc_paths(:test), do: ["lib", "test/support"]
|
||||
defp elixirc_paths(_), do: ["lib"]
|
||||
defp elixirc_paths(_), do: ["lib"]
|
||||
|
||||
# Specifies your project dependencies.
|
||||
#
|
||||
|
@ -72,7 +77,7 @@ defmodule Eventos.Mixfile do
|
|||
{:geolix, "~> 0.16"},
|
||||
# Dev and test dependencies
|
||||
{:phoenix_live_reload, "~> 1.0", only: :dev},
|
||||
{:ex_machina, "~> 2.1", only: :test},
|
||||
{:ex_machina, "~> 2.2", only: [:dev, :test]},
|
||||
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
|
||||
{:excoveralls, "~> 0.8", only: :test},
|
||||
{:ex_doc, "~> 0.16", only: :dev, runtime: false},
|
||||
|
@ -91,7 +96,7 @@ defmodule Eventos.Mixfile do
|
|||
[
|
||||
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
|
||||
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
||||
"test": ["ecto.create --quiet", "ecto.migrate", "test"]
|
||||
test: ["ecto.create --quiet", "ecto.migrate", "test"]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,15 +2,18 @@ defmodule Eventos.Repo.Migrations.Prerequites do
|
|||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
execute """
|
||||
execute("""
|
||||
CREATE TYPE datetimetz AS (
|
||||
dt timestamptz,
|
||||
tz varchar
|
||||
);
|
||||
"""
|
||||
""")
|
||||
|
||||
execute("CREATE EXTENSION IF NOT EXISTS postgis")
|
||||
end
|
||||
|
||||
def down do
|
||||
execute "DROP TYPE IF EXISTS datetimetz;"
|
||||
execute("DROP TYPE IF EXISTS datetimetz;")
|
||||
execute("DROP EXTENSION IF EXISTS postgis")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue