File Dockerfile of Package elixir-builder

#!BuildTag: counter:latest

# A dockerfile to grab some source code from github, compile and create a release,
#  and then create from the release a production container that executes it


# MIX_ENV dev, test, prod

FROM opensuse/tumbleweed as builder

# Source code of the application
ARG SRC_CODE=https://github.com/propedeutica/elixir-k8s-counter.git
ARG MIX_ENV=prod
ARG ELIXIR_VERSION=1.17.3



# Define where the source code can be found
ENV SRC_CODE=${SRC_CODE}

# Setting up locale so it does not complain about misconfigured latin1
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

ENV MIX_ENV=${MIX_ENV}

# The code will be in this directory in the image
ENV CODE=/app

# Changing working directory to restrain access
WORKDIR ${CODE}

# # Installation of elixir, nodejs, git and phoenix
RUN zypper --non-interactive install elixir npm-default git; \
    mix local.hex --force; \
    mix local.rebar --force

    # zypper clean -a; \ We won't be using this in production so no need to optimize

# Copying the source code into the working directory
# Using git
# RUN git clone ${SRC_CODE} ${CODE}
# Copy the code already downloaded
COPY source_code/ .

 # Compile assets and prepare release
ENV MIX_RELEASE=/app_release

RUN mix deps.get --only ${MIX_ENV};\
    mix deps.compile; \
    mix assets.deploy; \
    mix compile; \
    mix release --path /app_release


# # Generating a new image that will run the application
# # Prepare release image with the necessary components and install the release

FROM  opensuse/tumbleweed AS app

ARG MIX_ENV=prod
ARG SECRET_KEY_BASE

WORKDIR /deploy/
ENV HOME=/deploy
ENV MIX_ENV=${MIX_ENV}

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV SECRET_KEY_BASE=${SECRET_KEY_BASE}

# # Copying source code to the destination
COPY --from=builder --chown=nobody:root /app_release/ ./


# # This will be updated to a random user
USER nobody
EXPOSE 4000
# If using an environment that doesn't automatically reap zombie processes, it is
# advised to add an init process such as tini via `apt-get install`
# above and adding an entrypoint. See https://github.com/krallin/tini for details
# ENTRYPOINT ["/tini", "--"]

CMD ["/deploy/bin/server"]
openSUSE Build Service is sponsored by