From 94637a564c78c898cec87b838999f5650436196c Mon Sep 17 00:00:00 2001
From: Adam Piontek <adam@73k.us>
Date: Sun, 14 Aug 2022 15:14:14 -0400
Subject: [PATCH] added Dockerfile and entrypoint script

---
 Dockerfile    | 31 +++++++++++++++++++++++++++++++
 entrypoint.sh |  7 +++++++
 2 files changed, 38 insertions(+)
 create mode 100644 Dockerfile
 create mode 100755 entrypoint.sh

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..f572075d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,31 @@
+# ./Dockerfile
+
+# Extend from the official Elixir image
+FROM elixir:1.13.4-otp-25-alpine
+
+# # install the package postgresql-client to run pg_isready within entrypoint script
+# RUN apt-get update && \
+#   apt-get install -y postgresql-client
+
+# Create app directory and copy the Elixir project into it
+RUN mkdir /app
+COPY . /app
+WORKDIR /app
+
+# Install the build tools we'll need
+RUN apk update && \
+  apk upgrade --no-cache && \
+  apk add --no-cache \
+    build-base && \
+  mix local.rebar --force && \
+  mix local.hex --force
+
+
+# The environment to build with
+ENV MIX_ENV=prod
+
+# Get deps and compile
+RUN mix do deps.get, deps.compile, compile
+
+# Start command
+CMD = ["/app/entrypoint.sh"]
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100755
index 00000000..d6958f09
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,7 @@
+#!/bin/ash
+
+export MIX_ENV="prod"
+
+cd /app
+mix ecto.migrate
+exec mix phx.server