summaryrefslogtreecommitdiff
path: root/.github/dockerfiles/Dockerfile.ubuntu-base
blob: 4457d62a1fed351b750166736e278bd49a5a77a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
##
## This docker file will build a base image for building Erlang/OTP
##
ARG BASE=gitpod/workspace-full
FROM $BASE

ENV INSTALL_LIBS="zlib1g-dev libncurses5-dev libssl-dev unixodbc-dev libsctp-dev lksctp-tools libgmp3-dev libwxbase3.0-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev"

USER root

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

## Install build tools
RUN apt-get update && apt-get -y upgrade && \
    apt-get install -y build-essential m4 autoconf fop xsltproc \
    default-jdk libxml2-utils flex pkg-config locales tzdata sudo ${INSTALL_LIBS} && \
    sed -i 's@# en_US.UTF-8@en_US.UTF-8@g' /etc/locale.gen && locale-gen && \
    update-alternatives --set wx-config /usr/lib/x86_64-linux-gnu/wx/config/gtk3-unicode-3.0

ARG MAKEFLAGS=-j4
ENV MAKEFLAGS=$MAKEFLAGS \
    ERLC_USE_SERVER=yes

ENV LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8

ARG USER=gitpod
ARG GROUP=gitpod
ARG gid=10
ARG uid=421

RUN echo "Europe/Stockholm" > /etc/timezone && \
    ln -snf /usr/share/zoneinfo/$(cat /etc/timezone) /etc/localtime && \
    if ! grep ":${gid}:$" /etc/group; then groupadd -g ${gid} localgroup; fi && \
    if [ ! -d /home/${USER} ]; then useradd -rm -d /home/${USER} -s /bin/sh -g ${gid} -G ${gid},sudo -u ${uid} ${USER}; fi && \
    echo "${USER} ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} && \
    echo "/buildroot/** r," >> /etc/apparmor.d/local/usr.sbin.named && \
    echo "/tests/** r," >> /etc/apparmor.d/local/usr.sbin.named

## Java and log4j are used by fop to build documentation
COPY --chown=${USER}:${GROUP} dockerfiles/log4j.properties /home/${USER}/
ENV JAVA_ARGS="-Dlog4j.configuration=file://home/${USER}/log4j.properties"

ENV OTP_STRICT_INSTALL=yes

RUN mkdir /buildroot /tests /otp && chown ${USER}:${GROUP} /buildroot /tests /otp

## We install the latest version of the previous three releases in order to do
## backwards compatability testing of Erlang.
RUN apt-get install -y git curl && \
    curl -L https://raw.githubusercontent.com/kerl/kerl/master/kerl > /usr/bin/kerl && \
    chmod +x /usr/bin/kerl && \
    kerl update releases && \
    LATEST=$(kerl list releases | tail -1 | awk -F '.' '{print $1}') && \
    echo "/usr/local/lib/erlang-${LATEST}/bin" > /home/${USER}/LATEST && \
    for release in $(seq $(( LATEST - 2 )) $(( LATEST ))); do \
      VSN=$(kerl list releases | grep "^$release" | tail -1); \
      kerl build ${VSN} ${VSN} && \
      kerl install ${VSN} /usr/local/lib/erlang-${VSN}; \
    done && \
    rm -rf ~/.kerl

## Install test tools
## EXTRA_LIBS are installed using a for loop because of bugs in the erlang-doc deb package
## Apache2 may already be installed, if so we do not want to install it again
ARG EXTRA_LIBS="erlang erlang-doc"
RUN apt-get install -y \
    unixodbc odbc-postgresql postgresql ssh openssh-server groff-base gdb \
    tinyproxy bind9 nsd expect vsftpd python emacs nano vim \
    linux-tools-common linux-tools-generic linux-tools-`uname -r` jq \
    xvfb libgl1-mesa-dri && \
    for lib in ${EXTRA_LIBS}; do apt-get install -y ${lib}; done && \
    if [ ! -f /etc/apache2/apache2.conf ]; then apt-get install -y apache2; fi

## We use tmux to test terminals
RUN apt-get install -y libevent-dev libutf8proc-dev && \
    cd /tmp && wget https://github.com/tmux/tmux/releases/download/3.2a/tmux-3.2a.tar.gz && \
    tar xvzf tmux-3.2a.tar.gz && cd tmux-3.2a && \
    ./configure --enable-static --enable-utf8proc && \
    make && make install

## Setup progres so that the odbc test can run
USER postgres

RUN service postgresql start && \
    psql -c "CREATE USER odbctest WITH SUPERUSER PASSWORD 'odbctest';" && \
    createdb -O odbctest odbctest && \
    service postgresql stop

COPY --chown=root:${GROUP} dockerfiles/odbc.ini /etc/
COPY --chown=root:${GROUP} dockerfiles/odbcinst.ini /etc/

USER ${USER}

## Need to set USER and create a keygen file for ssh tests to pass
ENV USER=${USER}
RUN ssh-keygen -q -t rsa -N '' -f $HOME/.ssh/id_rsa && \
    cp $HOME/.ssh/id_rsa.pub $HOME/.ssh/authorized_keys

COPY --chown=${USER}:${GROUP} dockerfiles/init.sh /buildroot/

WORKDIR /buildroot/

## Install test tools rebar3, proper and jsx
RUN export PATH="$(cat /home/${USER}/LATEST)/${PATH}" && \
    latest () { \
    local VSN=$(curl -sL "https://api.github.com/repos/$1/tags" | jq -r ".[] | .name" | grep -E '^v?[0-9]' | sort -V | tail -1); \
    curl -sL "https://github.com/$1/archive/$VSN.tar.gz" > $(basename $1).tar.gz; \
    } && \
    latest erlang/rebar3 && ls -la && \
    (tar xzf rebar3.tar.gz && cd rebar3-* && ./bootstrap && sudo cp rebar3 /usr/bin) && \
    latest proper-testing/proper && \
    (tar xzf proper.tar.gz && mv proper-* proper && cd proper && make) && \
    latest talentdeficit/jsx && \
    (tar xzf jsx.tar.gz && mv jsx-* jsx && cd jsx && rebar3 compile)

ENV ERL_LIBS=/buildroot/proper:/buildroot/jsx

ENTRYPOINT ["/buildroot/init.sh"]