Commit 464810da authored by Frank's avatar Frank 👽
Browse files

Add docker build files

parent f643e0ec
ARG ALPINE_VERSION=3.8
FROM elixir:1.7.2-alpine AS builder
ARG APP_NAME
ARG APP_VSN
ARG MIX_ENV
ARG PHOENIX_SUBDIR=.
ENV APP_NAME=${APP_NAME} \
APP_VSN=${APP_VSN} \
MIX_ENV=${MIX_ENV}
# By convention, /opt is typically used for applications
WORKDIR /opt/gaja
# This step installs all the build tools we'll need
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
git \
build-base && \
mix local.rebar --force && \
mix local.hex --force
RUN git clone --single-branch --depth 1 https://gitlab.com/personal-server-community/personal-database.git /opt/gaja
RUN mix do deps.get, deps.compile, compile
RUN \
mkdir -p /opt/built && \
mix release --verbose && \
cp _build/${MIX_ENV}/rel/${APP_NAME}/releases/${APP_VSN}/${APP_NAME}.tar.gz /opt/built && \
cd /opt/built && \
tar -xzf ${APP_NAME}.tar.gz && \
rm ${APP_NAME}.tar.gz
FROM alpine:${ALPINE_VERSION}
ARG APP_NAME=gaja
RUN apk update && \
apk add --no-cache \
bash \
openssl-dev
ENV REPLACE_OS_VARS=true \
APP_NAME=${APP_NAME}
WORKDIR /opt/gaja
COPY --from=builder /opt/built .
CMD trap 'exit' INT; /opt/gaja/bin/${APP_NAME} foreground
.PHONY: help
APP_NAME ?= `grep 'app:' mix.exs | sed -e 's/\[//g' -e 's/ //g' -e 's/app://' -e 's/[:,]//g'`
APP_VSN ?= `grep 'version:' mix.exs | cut -d '"' -f2`
BUILD ?= `git rev-parse --short HEAD`
help:
@echo "$(APP_NAME):$(APP_VSN)-$(BUILD)"
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build: ## Build the Docker image
docker build --build-arg APP_NAME=$(APP_NAME) \
--build-arg APP_VSN=$(APP_VSN) \
--build-arg MIX_ENV=prod \
-t $(APP_NAME):$(APP_VSN)-$(BUILD) \
-t $(APP_NAME):latest .
run: ## Run the app in Docker
docker run --env-file config/docker.env \
--expose 4000 -p 4000:4000 \
--rm -it $(APP_NAME):latest
HOSTNAME=localhost
SECRET_KEY_BASE="u1QXlca4XEZKb1o3HL/aUlznI1qstCNAQ6yme/lFbFIs0Iqiq/annZ+Ty8JyUCDc"
DATABASE_HOST=db
DATABASE_USER=postgres
DATABASE_PASS=postgres
DATABASE_NAME=myapp_db
PORT=4000
LANG=en_US.UTF-8
REPLACE_OS_VARS=true
ERLANG_COOKIE=gaja
......@@ -9,12 +9,13 @@ use Mix.Config
# kept out of version control and might be hard to recover
# or recreate for your teammates (or yourself later on).
config :gaja, Gaja.Endpoint,
secret_key_base: "80uFIZUtGYfo69S+zieHRQHb1IJrFFyXlq5jzjHsh3ypk3Q1PCNZNrmTVg83eYhZ"
secret_key_base: System.get_env("SECRET_KEY_BASE")
# Configure your database
config :gaja, Gaja.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "gaja_prod",
username: System.get_env("DATABASE_USER"),
password: System.get_env("DATABASE_PASS"),
database: System.get_env("DATABASE_NAME"),
hostname: System.get_env("DATABASE_HOST"),
pool_size: 15
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment