From 761700386ced9167e1d37de89e969f23bb185653 Mon Sep 17 00:00:00 2001 From: Raphael Maenle Date: Tue, 11 Jan 2022 13:49:43 +0100 Subject: [PATCH] initial docker setup for bump --- bump/Dockerfile | 16 ++++++++++++++++ bump/setup.sh | 31 +++++++++++++++++++++++++++++++ docker-compose.yml | 26 ++++++++++++++++++++++++++ postgresql.conf | 2 ++ 4 files changed, 75 insertions(+) create mode 100644 bump/Dockerfile create mode 100755 bump/setup.sh create mode 100644 docker-compose.yml create mode 100644 postgresql.conf diff --git a/bump/Dockerfile b/bump/Dockerfile new file mode 100644 index 0000000..b9ad3fc --- /dev/null +++ b/bump/Dockerfile @@ -0,0 +1,16 @@ +# Elixir + Phoenix + +FROM elixir:1.12.2 + +# Install debian packages +RUN apt-get update +RUN apt-get install --yes build-essential inotify-tools postgresql-client + +# Install Phoenix packages +RUN mix local.hex --force +RUN mix local.rebar --force +RUN mix archive.install hex phx_new --force + +COPY setup.sh /usr/local/bin/ +EXPOSE 4012 +ENTRYPOINT ["setup.sh"] diff --git a/bump/setup.sh b/bump/setup.sh new file mode 100755 index 0000000..85611fb --- /dev/null +++ b/bump/setup.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Adapted from Alex Kleissner's post, Running a Phoenix 1.3 project with docker-compose +# https://medium.com/@hex337/running-a-phoenix-1-3-project-with-docker-compose-d82ab55e43cf + +cd /app/ +set -e + +# Ensure the app's dependencies are installed +mix deps.get --only prod + +#Analysis style code +# Prepare Credo if the project has Credo start code analyze +if mix help credo >/dev/null 2>&1 +then + echo "\nFound Credo: analyzing..." + mix credo || true +else + echo "\nNo Credo config: Skipping code analyze..." +fi + +# Potentially Set up the database +MIX_ENV=prod mix ecto.create +MIX_ENV=prod mix ecto.migrate + +echo "\nTesting the installation..." +# "Prove" that install was successful by running the tests +mix test + +echo "\n Launching Phoenix web server..." +# Start the phoenix web server +PORT=4012 MIX_ENV=prod mix phx.server diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9f79a8c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3' +services: + database: + image: postgres + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=db + restart: unless-stopped + volumes: + - ./postgres-data:/var/lib/postgresql/data + - ./postgresql.conf:/etc/postgresql.conf + command: postgres -c config_file=/etc/postgresql.conf + ports: + - "5555:5555" + bump-server: + build: + context: ./bump + image: maenle/bump-server:latest + container_name: bump-server + volumes: + - ../bump_server:/app + ports: + - "4012:4012" + depends_on: + - database diff --git a/postgresql.conf b/postgresql.conf new file mode 100644 index 0000000..f111e96 --- /dev/null +++ b/postgresql.conf @@ -0,0 +1,2 @@ +port = 5555 +listen_addresses='*'