# SPDX-License-Identifier: Apache-2.0
#!BuildTag: trento/trento-wanda:latest
#!BuildTag: trento/trento-wanda:1.3.0
#!BuildTag: trento/trento-wanda:1.3.0-build%RELEASE%
#!UseOBSRepositories
#!ExclusiveArch: x86_64

FROM bci/rust:1.66 AS release
ADD wanda.tar.gz premium-checks.tar.gz* /build/
RUN mv /build/priv/catalog/* /build/wanda/priv/catalog || true && rm -fr /build/priv/
# Workaround for https://github.com/openSUSE/obs-build/issues/487
RUN zypper --non-interactive in sles-release
RUN zypper -n in git-core elixir>=1.15 elixir-hex erlang-rebar3
WORKDIR /build/wanda/
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV MIX_ENV=prod
ENV MIX_HOME=/usr/bin
ENV MIX_REBAR3=/usr/bin/rebar3
ENV MIX_PATH=/usr/lib/elixir/lib/hex/ebin
ENV VERSION=1.3.0
RUN mix phx.digest
RUN mix release

FROM bci/rust:1.66 AS wanda
# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.trento
LABEL org.opencontainers.image.source="https://github.com/trento-project/wanda"
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR /app
COPY --from=release /build/wanda/_build/prod/rel/wanda .
EXPOSE 4000/tcp
ENTRYPOINT ["/app/bin/wanda"]
