diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b3edbab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,73 @@ +# https://cloud.google.com/community/tutorials/elixir-phoenix-on-kubernetes-google-container-engine +# Build time container +ARG ALPINE_VERSION=3.15 + +FROM elixir:1.13.3-alpine AS builder + +ARG app_name=farside +ARG subdir=. +ARG build_env=prod +ARG SOURCE_VERSION +ARG COMMIT=${SOURCE_VERSION} +ARG MIX_ENV=prod + +ENV APP_NAME=${app_name} \ + MIX_ENV=${MIX_ENV} \ + COMMIT=${COMMIT} + +ENV REPLACE_OS_VARS=true +ENV MIX_ENV=${build_env} TERM=xterm + +RUN set -ex && \ + apk update && \ + apk upgrade --no-cache && \ + apk add --no-cache \ + git \ + curl \ + nodejs \ + npm \ + python3 \ + build-base && \ + mix local.rebar --force && \ + mix local.hex --force && \ + mkdir -p /opt/built + +RUN mkdir /app +COPY . /app +WORKDIR /app + +RUN mix do deps.get, compile +RUN cd ${subdir}/assets \ + && npm install \ + && npm run deploy \ + && cd .. \ +RUN mix release ${app_name} \ + && mv _build/${build_env}/rel/${app_name} /opt/release \ + && mv /opt/release/bin/${app_name} /opt/release/bin/server + +# Runtime container +FROM alpine:${ALPINE_VERSION}est + +RUN set -ex && \ + apk update && \ + apk add --no-cache \ + bash \ + curl \ + gcc \ + nodejs-current \ + libstdc++ \ + openssl-dev && \ + curl https://raw.githubusercontent.com/eficode/wait-for/f71f8199a0dd95953752fb5d3f76f79ced16d47d/wait-for -o /usr/local/bin/wait-for && \ + chmod +x /usr/local/bin/wait-for + +# For local dev, heroku will ignore this +EXPOSE $PORT + +WORKDIR /opt/app +COPY --from=0 /opt/release . +RUN addgroup -S elixir && adduser -H -D -S -G elixir elixir +RUN chown -R elixir:elixir /opt/app +USER elixir + +# Heroku sets magical $PORT variable +CMD PORT=$PORT diff --git a/README.md b/README.md index b8bb525..48c5050 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Latest Release](https://img.shields.io/github/v/release/benbusby/farside?label=Release)](https://github.com/benbusby/farside/releases) [![MIT License](https://img.shields.io/github/license/benbusby/earthbound-themes.svg)](http://opensource.org/licenses/MIT) [![Elixir CI](https://github.com/benbusby/privacy-revolver/actions/workflows/elixir.yml/badge.svg)](https://github.com/benbusby/privacy-revolver/actions/workflows/elixir.yml) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) A redirecting service for FOSS alternative frontends. diff --git a/app.json b/app.json new file mode 100644 index 0000000..825aa87 --- /dev/null +++ b/app.json @@ -0,0 +1,13 @@ +{ + "name": "Farside", + "description": "A redirecting service for FOSS alternative frontends", + "repository": "https://github.com/data-twister/farside", + "logo": "", + "keywords": ["elixir", "farside" ], + "addons": [ "heroku-postgresql"], + "buildpacks": [ + { + "url": "https://github.com/HashNuke/heroku-buildpack-elixir.git" + } + ] +} \ No newline at end of file diff --git a/elixir_buildpack.config b/elixir_buildpack.config new file mode 100644 index 0000000..8675ab1 --- /dev/null +++ b/elixir_buildpack.config @@ -0,0 +1,4 @@ + +elixir_version=1.12.3 +erlang_version=24.2.1 +clean_cache=true \ No newline at end of file