Skip to content
Merged
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
26 changes: 0 additions & 26 deletions src/usr/local/buildpack/tools/elixir.sh

This file was deleted.

71 changes: 0 additions & 71 deletions src/usr/local/buildpack/tools/erlang.sh

This file was deleted.

33 changes: 33 additions & 0 deletions src/usr/local/buildpack/tools/v2/elixir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

function install_tool () {
local versioned_tool_path

check_command erl

versioned_tool_path=$(create_versioned_tool_path)
create_folder "${versioned_tool_path}/bin"

local file
file=$(get_from_url "https://github.com/elixir-lang/elixir/releases/download/v${TOOL_VERSION}/Precompiled.zip")
unzip -q "${file}" -d "${versioned_tool_path}"
}

function link_tool () {
local versioned_tool_path
versioned_tool_path=$(find_versioned_tool_path)

shell_wrapper "${TOOL_NAME}" "${versioned_tool_path}/bin"
shell_wrapper mix "${versioned_tool_path}/bin"

elixir --version
mix --version

if [[ $(is_root) -eq 0 ]]; then
su -c 'mix local.hex --force' "${USER_NAME}"
su -c 'mix local.rebar --force' "${USER_NAME}"
else
mix local.hex --force
mix local.rebar --force
fi
}
81 changes: 81 additions & 0 deletions src/usr/local/buildpack/tools/v2/erlang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

SEMVER_REGEX="^(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?(\.(0|[1-9][0-9]*))?(\.(0|[1-9][0-9]*))?(\+[0-9]+)?([a-z-].*)?$"

function check_semver () {
if [[ ! "${1}" =~ ${SEMVER_REGEX} ]]; then
echo Not a semver like version - aborting: "${1}"
exit 1
fi
export MAJOR=${BASH_REMATCH[1]}
export MINOR=${BASH_REMATCH[3]}
export PATCH=${BASH_REMATCH[5]}
export BUILD=${BASH_REMATCH[7]}
}

function check_tool_requirements () {
check_semver "${TOOL_VERSION}"
if [[ ! "${MAJOR}" || ! "${MINOR}" || ! "${PATCH}" || ! "${BUILD}" ]]; then
echo Invalid version: "${TOOL_VERSION}"
exit 1
fi
}

function prepare_tool() {
local version_codename

version_codename=$(get_distro)
case "$version_codename" in
"bionic") apt_install \
libodbc1 \
libssl1.1 \
libsctp1 \
;;
"focal") apt_install \
libodbc1 \
libssl1.1 \
libsctp1 \
;;
esac

local tool_path
tool_path=$(create_tool_path)

# workaround https://github.com/containerbase/buildpack/issues/377
ln -sf "$tool_path" /usr/local/erlang
}

function install_tool () {
local tool_path
local file
local BASE_URL
local ARCH
local version_codename

tool_path=$(find_tool_path)

if [[ ! -d "${tool_path}" ]]; then
if [[ $(is_root) -ne 0 ]]; then
echo "${TOOL_NAME} not prepared"
exit 1
fi
prepare_tool
tool_path=$(find_tool_path)
fi

ARCH=$(uname -p)
BASE_URL="https://github.com/containerbase/${TOOL_NAME}-prebuild/releases/download"
version_codename=$(get_distro)

file=$(get_from_url "${BASE_URL}/${TOOL_VERSION}/${TOOL_NAME}-${TOOL_VERSION}-${version_codename}-${ARCH}.tar.xz")
tar -C "${tool_path}" -xf "${file}"
}

function link_tool () {
local versioned_tool_path
versioned_tool_path=$(find_versioned_tool_path)

export_tool_env ERL_ROOTDIR "${versioned_tool_path}"
shell_wrapper erl "${versioned_tool_path}/bin"
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
}
56 changes: 48 additions & 8 deletions test/erlang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,65 @@
ARG IMAGE=containerbase/buildpack
FROM ${IMAGE}
FROM ${IMAGE} as build

ARG APT_HTTP_PROXY
RUN touch /.dummy

# Erlang
# test openshift compatibility 1000<>1001
COPY --chown=1001:0 test test

WORKDIR /test

#--------------------------------------
# test: erlang (root)
#--------------------------------------
FROM build as testa

ARG APT_HTTP_PROXY
ARG BUILDPACK_DEBUG

# renovate: datasource=github-releases lookupName=containerbase/erlang-prebuild versioning=docker
RUN install-tool erlang 24.3.3.0

# Elixir

# renovate: datasource=docker versioning=docker
RUN install-tool elixir 1.13.4

# test openshift compatibility 1000<>1001
COPY --chown=1001:0 test test

WORKDIR /test
USER 1001

RUN set -ex; \
cd a; \
mix deps.update --all;


#--------------------------------------
# test: erlang (user,openshift)
#--------------------------------------
FROM build as testb

ARG APT_HTTP_PROXY
ARG BUILDPACK_DEBUG

RUN prepare-tool erlang

USER 1001

# renovate: datasource=github-releases lookupName=containerbase/erlang-prebuild versioning=docker
RUN install-tool erlang 24.3.3.0

ARG BUILDPACK_DEBUG

# renovate: datasource=docker versioning=docker
RUN install-tool elixir 1.13.4


RUN set -ex; \
cd a; \
mix deps.update --all;


#--------------------------------------
# final
#--------------------------------------
FROM build

COPY --from=testa /.dummy /.dummy
COPY --from=testb /.dummy /.dummy