Skip to content

Commit 738c8a3

Browse files
authored
Merge pull request #68 from internetee/upgrade-dockerfile
Upgraded and created dockerfiles
2 parents 99b7146 + 626cb07 commit 738c8a3

21 files changed

Lines changed: 419 additions & 104 deletions

.github/workflows/build_base_image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ jobs:
99

1010
build:
1111

12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313

1414
steps:
1515

16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717

1818
- name: Get versions
1919
shell: python

.github/workflows/run-automatest-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on: [push]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-22.04
88
steps:
9-
- uses: actions/checkout@v2.0.0
9+
- uses: actions/checkout@v3
1010

1111
- name: Build image for tests
1212
run: docker build -t proxy-tester -f Dockerfile.test .
@@ -15,19 +15,19 @@ jobs:
1515
run: docker run -d --name tester proxy-tester
1616

1717
- name: Install rebar dependencies
18-
run: docker exec -i tester rebar3 as test get-deps
18+
run: docker exec -i tester bash -l -c "source /root/.asdf/asdf.sh && rebar3 as test get-deps"
1919

2020
- name: Integrated Ruby app setup
2121
run: docker exec -d tester bash -l -c "cd apps/epp_proxy/priv/test_backend_app && bundle install && bundle exec rackup"
2222

2323
- name: Compile for tests
2424
run: |
2525
sleep 15
26-
docker exec -i tester rebar3 as test compile
26+
docker exec -i tester bash -l -c "source /root/.asdf/asdf.sh && rebar3 as test compile"
2727
2828
- name: Run tests
2929
run: |
30-
docker exec -i -e DEBUG=1 tester rebar3 ct --sys_config config/test.config --readable=false --cover --verbose=true
30+
docker exec -i -e DEBUG=1 tester bash -l -c "source /root/.asdf/asdf.sh && rebar3 ct --sys_config config/test.config --readable=false --cover --verbose=true"
3131
3232
- name: Show test coverage
33-
run: docker exec -i tester rebar3 cover --verbose
33+
run: docker exec -i tester bash -l -c "source /root/.asdf/asdf.sh && rebar3 cover --verbose"

.tool-versions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
erlang 21.3.8
2-
ruby 2.6.3
3-
rebar 3.11.0
1+
erlang 23.3.4.20
2+
ruby 3.2.2
3+
rebar 3.15.2

Dockerfile

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,48 @@
1-
FROM debian:buster-slim
1+
FROM debian:bullseye-slim
22

33
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
44
COPY ./docker/apt/sources.list /etc/apt/
55

6-
RUN apt-get update && apt-get -t buster install -y -qq wget \
7-
&& apt-get clean \
8-
&& rm -rf /var/lib/apt/lists/*
9-
10-
11-
RUN apt-get update && apt-get install -y -qq git \
12-
&& apt-get clean \
13-
&& rm -rf /var/lib/apt/lists/*
14-
15-
RUN apt-get update && apt-get install -y \
16-
build-essential=* \
17-
libncurses5-dev=* \
18-
automake=* \
19-
autoconf=* \
20-
curl=* \
21-
ca-certificates=* \
22-
libssl-dev=* \
23-
libreadline-dev=* \
24-
libdpkg-perl=* \
25-
liberror-perl=* \
26-
libc6=* \
6+
# Install all dependencies in a single layer to reduce image size
7+
RUN apt-get update && apt-get install -y -qq \
8+
wget \
9+
git \
10+
build-essential \
11+
libncurses5-dev \
12+
automake \
13+
autoconf \
14+
curl \
15+
ca-certificates \
16+
libssl-dev \
17+
libreadline-dev \
18+
libdpkg-perl \
19+
liberror-perl \
20+
libc6 \
2721
libc-dev \
28-
perl=* \
29-
procps=* \
30-
inotify-tools=* \
31-
libssl1.1=* \
32-
perl-base=* \
22+
perl \
23+
procps \
24+
inotify-tools \
25+
libssl1.1 \
26+
perl-base \
3327
zlib1g-dev \
28+
# Additional dependencies for Erlang build
29+
libncurses-dev \
30+
libsctp-dev \
31+
# Documentation tools to prevent build failures
32+
xsltproc \
33+
libxml2-utils \
34+
# Dependencies for Ruby 3.2.2
35+
libffi-dev \
36+
libyaml-dev \
3437
&& apt-get clean \
3538
&& rm -rf /var/lib/apt/lists/*
3639

37-
# RUN (groupadd -g 999 asdf || true)
38-
# RUN (adduser --shell /bin/bash --home /asdf --disabled-password -gid 999 -u 999 asdf || true)
39-
# ENV PATH="${PATH}:/asdf/.asdf/shims:/asdf/.asdf/bin"
40-
# USER asdf
41-
# WORKDIR /asdf
40+
# Set environment variables for Erlang build
41+
ENV KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --without-wx --without-odbc --disable-hipe --without-jinterface --without-docs"
42+
ENV KERL_BUILD_DOCS="no"
43+
ENV KERL_DOC_TARGETS=""
44+
ENV KERL_INSTALL_HTMLDOCS="no"
45+
ENV KERL_INSTALL_MANPAGES="no"
4246

4347
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
4448
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
@@ -51,7 +55,7 @@ WORKDIR /opt/erlang/epp_proxy
5155

5256
COPY .tool-versions ./
5357
RUN asdf plugin-add erlang
54-
RUN asdf install
58+
RUN . $HOME/.asdf/asdf.sh && asdf install
5559
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
5660
RUN asdf plugin-add ruby
5761
RUN asdf plugin-add rebar

Dockerfile.Erlang-ruby.base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:buster-slim
1+
FROM debian:bullseye-slim
22

33
RUN apt-get update && apt-get install -y \
44
wget \

Dockerfile.amd64.legacy

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
FROM debian:buster-slim
2+
3+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4+
COPY ./docker/apt/sources.list /etc/apt/
5+
6+
RUN apt-get update && apt-get -t buster install -y -qq wget \
7+
&& apt-get clean \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
11+
RUN apt-get update && apt-get install -y -qq git \
12+
&& apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
RUN apt-get update && apt-get install -y \
16+
build-essential=* \
17+
libncurses5-dev=* \
18+
automake=* \
19+
autoconf=* \
20+
curl=* \
21+
ca-certificates=* \
22+
libssl-dev=* \
23+
libreadline-dev=* \
24+
libdpkg-perl=* \
25+
liberror-perl=* \
26+
libc6=* \
27+
libc-dev \
28+
perl=* \
29+
procps=* \
30+
inotify-tools=* \
31+
libssl1.1=* \
32+
perl-base=* \
33+
zlib1g-dev \
34+
&& apt-get clean \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
# RUN (groupadd -g 999 asdf || true)
38+
# RUN (adduser --shell /bin/bash --home /asdf --disabled-password -gid 999 -u 999 asdf || true)
39+
# ENV PATH="${PATH}:/asdf/.asdf/shims:/asdf/.asdf/bin"
40+
# USER asdf
41+
# WORKDIR /asdf
42+
43+
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
44+
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
45+
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.profile
46+
47+
ENV PATH="${PATH}:/root/.asdf/shims:/root/.asdf/bin"
48+
49+
RUN mkdir -p /opt/erlang/epp_proxy
50+
WORKDIR /opt/erlang/epp_proxy
51+
52+
COPY .tool-versions ./
53+
RUN asdf plugin-add erlang
54+
RUN asdf install
55+
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
56+
RUN asdf plugin-add ruby
57+
RUN asdf plugin-add rebar
58+
RUN asdf install

Dockerfile.k8s

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
FROM debian:bullseye-slim AS build
2+
3+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4+
COPY ./docker/apt/sources.list /etc/apt/
5+
6+
# Install build dependencies
7+
RUN apt-get update && apt-get install -y -qq \
8+
wget \
9+
git \
10+
build-essential \
11+
libncurses5-dev \
12+
automake \
13+
autoconf \
14+
curl \
15+
ca-certificates \
16+
libssl-dev \
17+
libreadline-dev \
18+
libdpkg-perl \
19+
liberror-perl \
20+
libc6 \
21+
libc-dev \
22+
perl \
23+
procps \
24+
inotify-tools \
25+
libssl1.1 \
26+
perl-base \
27+
zlib1g-dev \
28+
libncurses-dev \
29+
libsctp-dev \
30+
xsltproc \
31+
libxml2-utils \
32+
&& apt-get clean \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
# Set environment variables for Erlang build
36+
ENV KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --without-wx --without-odbc --disable-hipe --without-jinterface --without-docs"
37+
ENV KERL_BUILD_DOCS="no"
38+
ENV KERL_DOC_TARGETS=""
39+
ENV KERL_INSTALL_HTMLDOCS="no"
40+
ENV KERL_INSTALL_MANPAGES="no"
41+
42+
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
43+
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
44+
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.profile
45+
46+
ENV PATH="${PATH}:/root/.asdf/shims:/root/.asdf/bin"
47+
48+
RUN mkdir -p /opt/erlang/epp_proxy
49+
WORKDIR /opt/erlang/epp_proxy
50+
51+
COPY .tool-versions ./
52+
RUN asdf plugin-add erlang
53+
RUN ERLANG_VERSION=$(grep erlang .tool-versions | cut -d' ' -f2) && \
54+
. $HOME/.asdf/asdf.sh && asdf install erlang $ERLANG_VERSION
55+
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
56+
RUN asdf plugin-add rebar
57+
RUN REBAR_VERSION=$(grep rebar .tool-versions | cut -d' ' -f2) && \
58+
. $HOME/.asdf/asdf.sh && asdf install rebar $REBAR_VERSION
59+
RUN asdf global rebar $(grep rebar .tool-versions | cut -d' ' -f2)
60+
61+
# Copy application files
62+
COPY rebar.config rebar.lock ./
63+
COPY config ./config
64+
COPY apps ./apps
65+
66+
# Build the release
67+
RUN . $HOME/.asdf/asdf.sh && rebar3 as prod release
68+
69+
# Second stage: runtime image
70+
FROM debian:bullseye-slim
71+
72+
# Install runtime dependencies only
73+
RUN apt-get update && apt-get install -y -qq \
74+
libssl1.1 \
75+
libncurses6 \
76+
libsctp1 \
77+
procps \
78+
&& apt-get clean \
79+
&& rm -rf /var/lib/apt/lists/*
80+
81+
# Create app directory
82+
RUN mkdir -p /opt/erlang/epp_proxy
83+
WORKDIR /opt/erlang/epp_proxy
84+
85+
# Copy the release from the build stage
86+
COPY --from=build /opt/erlang/epp_proxy/_build/prod/rel/epp_proxy ./
87+
88+
# Create a non-root user to run the application
89+
RUN groupadd -r epp && useradd -r -g epp epp
90+
RUN chown -R epp:epp /opt/erlang/epp_proxy
91+
USER epp
92+
93+
# Expose the EPP port
94+
EXPOSE 700
95+
96+
# Set environment variables
97+
ENV RELX_REPLACE_OS_VARS=true
98+
ENV NODE_NAME=epp_proxy@127.0.0.1
99+
100+
# Health check
101+
# HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
102+
# CMD ps aux | grep "beam" | grep -v grep || exit 1
103+
104+
# Command to run the application
105+
CMD ["./bin/epp_proxy", "foreground"]

Dockerfile.test

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,68 @@
1-
FROM internetee/erlang-ruby:21.3.8-2.6.3
1+
FROM debian:bullseye-slim
2+
3+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4+
COPY ./docker/apt/sources.list /etc/apt/
5+
6+
# Install all dependencies in a single layer to reduce image size
7+
RUN apt-get update && apt-get install -y -qq \
8+
wget \
9+
git \
10+
build-essential \
11+
libncurses5-dev \
12+
automake \
13+
autoconf \
14+
curl \
15+
ca-certificates \
16+
libssl-dev \
17+
libreadline-dev \
18+
libdpkg-perl \
19+
liberror-perl \
20+
libc6 \
21+
libc-dev \
22+
perl \
23+
procps \
24+
inotify-tools \
25+
libssl1.1 \
26+
perl-base \
27+
zlib1g-dev \
28+
# Additional dependencies for Erlang build
29+
libncurses-dev \
30+
libsctp-dev \
31+
# Documentation tools to prevent build failures
32+
xsltproc \
33+
libxml2-utils \
34+
# Dependencies for Ruby 3.2.2
35+
libffi-dev \
36+
libyaml-dev \
37+
&& apt-get clean \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
# Set environment variables for Erlang build
41+
ENV KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --without-wx --without-odbc --disable-hipe --without-jinterface --without-docs"
42+
ENV KERL_BUILD_DOCS="no"
43+
ENV KERL_DOC_TARGETS=""
44+
ENV KERL_INSTALL_HTMLDOCS="no"
45+
ENV KERL_INSTALL_MANPAGES="no"
46+
47+
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
48+
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
49+
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.profile
50+
51+
ENV PATH="${PATH}:/root/.asdf/shims:/root/.asdf/bin"
52+
53+
RUN mkdir -p /opt/erlang/epp_proxy
54+
WORKDIR /opt/erlang/epp_proxy
55+
56+
COPY .tool-versions ./
57+
RUN asdf plugin-add erlang
58+
RUN . $HOME/.asdf/asdf.sh && asdf install
59+
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
60+
RUN asdf plugin-add ruby
61+
RUN asdf plugin-add rebar
62+
RUN asdf install
63+
64+
# Copy the application code
265
COPY . .
366

4-
CMD ["tail", "-f" , "/dev/null"]
67+
# Keep container running for tests
68+
CMD ["tail", "-f", "/dev/null"]

0 commit comments

Comments
 (0)