hexlet-codebattle/codebattle

View on GitHub
services/app/Dockerfile.runner

Summary

Maintainability
Test Coverage
FROM elixir:1.16-alpine AS compile-image
ENV MIX_ENV=prod

WORKDIR /opt/app

RUN mix local.hex --force \
  && mix local.rebar --force

COPY mix.exs .
COPY mix.lock .
COPY config ./config
COPY apps/runner/mix.exs apps/runner/mix.exs

RUN apk update && apk add --no-cache ca-certificates git make curl

RUN mix do deps.get --only prod, compile

COPY ./apps/runner/ ./apps/runner/

RUN mix release runner \
  && mv _build/prod/rel/runner /opt/release

FROM elixir:1.16-alpine AS runtime-image

ENV DOCKER_CHANNEL stable
ENV DOCKER_VERSION 24.0.9

ENV GOON_VERSION v1.1.1


RUN apk update && apk add --no-cache ca-certificates git make curl vim

RUN curl -fsSL "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz" \
  | tar -xzC /usr/local/bin --strip=1 docker/docker

RUN curl -fsSL "https://github.com/alco/goon/releases/download/${GOON_VERSION}/goon_linux_amd64.tar.gz" \
  | tar -xzC /usr/local/bin

ENV PORT=4001
EXPOSE ${PORT}
WORKDIR /opt/app
COPY --from=compile-image /opt/release .
COPY Makefile Makefile
CMD exec /opt/app/bin/runner start