diff --git a/Dockerfile b/Dockerfile index 78a3587..3b53002 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 . @@ -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"] diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..731ae9b --- /dev/null +++ b/compose.yml @@ -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' \ No newline at end of file diff --git a/config/runtime.exs b/config/runtime.exs index c2d7a0c..dd50d8e 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -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"))