Skip to content

Instantly share code, notes, and snippets.

@jaggy
Last active September 5, 2018 00:05
Show Gist options
  • Save jaggy/9a4c726e18ddb4450403fe5009979645 to your computer and use it in GitHub Desktop.
Save jaggy/9a4c726e18ddb4450403fe5009979645 to your computer and use it in GitHub Desktop.
FROM elixir:latest
RUN mix local.hex --force
RUN mix local.rebar --force
RUN mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez --force
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y postgresql-client inotify-tools nodejs
RUN mkdir /app
COPY . /app
WORKDIR /app
#!/bin/bash
# Create, migrate, and seed database if it doesn't exist.
if [[ -z `psql -U $POSTGRES_USER -Atqc "\\list merchant"` ]]; then
echo "Database merchant does not exist. Creating..."
createdb -U $POSTGRES_USER -E UTF8 merchant -l en_US.UTF-8 -T template0
mix ecto.migrate
mix run priv/repo/seeds.exs
echo "Database merchant created."
fi
version: '3'
services:
app:
build:
context: .
dockerfile: docker/app/Dockerfile
working_dir: /app
command: mix phx.server
environment:
PGUSERNAME: postgres
PGPASSWORD: postgres
PGDATABASE: merchant
PGHOSTNAME: database
PGPORT: 5432
ports:
- 4000:4000
volumes:
- .:/app
links:
- postgres:database
postgres:
image: postgres:9.6
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PGDATA: /var/lib/postgres/data/pgdata
restart: always
volumes:
- ./docker/postgres:/docker-entrypoint-initdb.d
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment