Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker config for development env
- Loading branch information
1 parent
d958e74
commit d6b1a45
Showing
7 changed files
with
124 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ npm-debug.log | |
|
||
# Add coveralls folder | ||
/cover | ||
|
||
# ElixirLS Dialyzer | ||
.elixir_ls/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: '3' | ||
|
||
services: | ||
# Phoenix app | ||
app: | ||
build: | ||
context: . | ||
dockerfile: ./docker/Dockerfile | ||
args: | ||
HOST_USER_UID: ${HOST_USER_UID} | ||
HOST_GROUP_GID: ${HOST_GROUP_GID} | ||
container_name: openpace-app | ||
volumes: | ||
- .:/app/ | ||
env_file: | ||
- .env | ||
ports: | ||
- 4000:4000 | ||
depends_on: | ||
- db | ||
|
||
# Postgres | ||
db: | ||
image: postgres:latest | ||
container_name: openpace-db | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
restart: always | ||
env_file: | ||
- .env | ||
|
||
volumes: | ||
pgdata: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM elixir:1.9 | ||
|
||
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash | ||
|
||
# Install depenencies | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
inotify-tools \ | ||
apt-transport-https \ | ||
apt-utils \ | ||
postgresql-client \ | ||
nodejs | ||
|
||
# Install yarn | ||
RUN npm install -g yarn | ||
|
||
# Create openpace user and group from host to avoid permission issues | ||
ARG HOST_GROUP_GID | ||
ARG HOST_USER_UID | ||
RUN addgroup --gid $HOST_GROUP_GID openpace && \ | ||
useradd -m -u $HOST_USER_UID -g $HOST_GROUP_GID openpace | ||
|
||
# Set permissions to the app folder | ||
ARG APP_DIR='/app' | ||
RUN mkdir -p $APP_DIR && \ | ||
chown -R openpace:openpace $APP_DIR | ||
|
||
USER openpace | ||
|
||
RUN mix local.hex --force && mix local.rebar --force | ||
|
||
WORKDIR $APP_DIR | ||
|
||
ENTRYPOINT ["sh", "/app/docker/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
# Docker entrypoint script. | ||
|
||
cd $(dirname $0)/.. | ||
export APP_DIR=$(pwd) | ||
export ASSETS_DIR=${APP_DIR}/assets | ||
|
||
# Install new dependencies | ||
mix deps.get | ||
|
||
# Wait until Postgres is ready | ||
while ! pg_isready -q -h $POSTGRES_HOST -p 5432 -U $POSTGRES_USER | ||
do | ||
echo "$(date) - waiting for database to start." | ||
sleep 2 | ||
done | ||
|
||
# Create and migrate database | ||
mix ecto.create | ||
mix ecto.migrate | ||
|
||
# Install yarn packages | ||
cd ${ASSETS_DIR} | ||
yarn install | ||
cd ${APP_DIR} | ||
|
||
echo "Starting Phoenix server..." | ||
exec mix phx.server |