Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# syntax=docker/dockerfile:1

###
FROM elixir:1.13.4-alpine AS builder

#
ARG MIX_ENV=prod
ENV MIX_ENV=${MIX_ENV}

ARG PORT

WORKDIR /app

COPY mix.exs .
Expand All @@ -13,14 +22,17 @@ RUN mix deps.get
COPY lib/ ./lib/
COPY config/ ./config/

ENV MIX_ENV=prod
RUN mix release

###
FROM elixir:1.13.4-alpine

#
ARG MIX_ENV=prod
ENV MIX_ENV=${MIX_ENV}

WORKDIR /app

COPY --from=builder /app/_build/prod/rel/prod/ ./_build/prod/rel/prod/
COPY --from=builder /app/_build/${MIX_ENV}/rel/prod/ ./_build/${MIX_ENV}/rel/prod/

ENV MIX_ENV=prod
CMD ["_build/prod/rel/prod/bin/prod", "start"]
CMD ["sh", "-c", "_build/${MIX_ENV}/rel/prod/bin/prod start"]
21 changes: 21 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
###
services:
# docker buildx bake
srh:
build:
context: .
dockerfile: Dockerfile
platforms:
- linux/amd64
- linux/arm64
args:
- MIX_ENV=${MIX_ENV:-runtime}
- PORT=${PORT:-80}
ports:
- '8079:${PORT:-80}'
image: local/serverless-redis-http
environment:
SRH_PORT: ${PORT:-80}
SRH_MODE: env
SRH_TOKEN: example_token
SRH_CONNECTION_STRING: 'redis://redis:6379'
2 changes: 1 addition & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Config
config :srh,
mode: System.get_env("TOKEN_RESOLUTION_MODE") || "file",
file_path: System.get_env("TOKEN_RESOLUTION_FILE_PATH") || "srh-config/tokens.json",
port: Integer.parse(System.get_env("PORT") || "8080")
port: String.to_integer(System.get_env("PORT", "8080"))