add deploy to heroku

This commit is contained in:
mithereal 2022-07-29 23:11:34 -07:00
parent 7bd91cbcad
commit d69b859910
4 changed files with 91 additions and 0 deletions

73
Dockerfile Normal file
View File

@ -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

View File

@ -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.

13
app.json Normal file
View File

@ -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"
}
]
}

4
elixir_buildpack.config Normal file
View File

@ -0,0 +1,4 @@
elixir_version=1.12.3
erlang_version=24.2.1
clean_cache=true