forked from jpculp/ga2ecr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
70 lines (54 loc) · 1.86 KB
/
Dockerfile
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
FROM public.ecr.aws/amazonlinux/amazonlinux:2 as builder
RUN yum group install -y "Development Tools"
RUN yum install -y glibc-static
ARG musl_version=1.2.2
ARG bash_version=5.0
ARG bash_patch_level=18
WORKDIR /opt/build
COPY ./sdk-fetch ./
WORKDIR /opt/build
COPY ./hashes/musl ./hashes
RUN \
./sdk-fetch hashes && \
tar -xf musl-${musl_version}.tar.gz && \
rm musl-${musl_version}.tar.gz hashes
WORKDIR /opt/build/musl-${musl_version}
RUN ./configure --enable-static && make -j$(nproc) && make install
WORKDIR /opt/build
COPY ./hashes/bash ./hashes
RUN \
./sdk-fetch hashes && \
tar -xf bash-${bash_version}.tar.gz && \
rm bash-${bash_version}.tar.gz hashes
WORKDIR /opt/build/bash-${bash_version}
RUN for patch_level in $(seq ${bash_patch_level}); do \
patch -p0 < /opt/build/bash${bash_version//.}-$(printf '%03d' $patch_level); \
done
RUN CC=""/usr/local/musl/bin/musl-gcc CFLAGS="-Os -DHAVE_DLOPEN=0" \
./configure \
--enable-static-link \
--without-bash-malloc \
|| { cat config.log; exit 1; }
RUN make -j`nproc`
RUN cp bash /opt/bash
FROM public.ecr.aws/amazonlinux/amazonlinux:2
ARG IMAGE_VERSION
# Make the container image version a mandatory build argument
RUN test -n "$IMAGE_VERSION"
LABEL "org.opencontainers.image.version"="$IMAGE_VERSION"
RUN yum install -y openssh-server sudo util-linux procps-ng jq \
&& yum clean all
COPY --from=builder /opt/bash /opt/bin/
RUN rm -f /etc/motd /etc/issue
ADD --chown=root:root motd /etc/
ADD --chown=root:root ec2-user.sudoers /etc/sudoers.d/ec2-user
ADD start_admin_sshd.sh /usr/sbin/
ADD ./sshd_config /etc/ssh/
ADD ./sheltie /usr/bin/
RUN chmod 440 /etc/sudoers.d/ec2-user
RUN chmod +x /usr/sbin/start_admin_sshd.sh
RUN chmod +x /usr/bin/sheltie
RUN groupadd -g 274 api
RUN useradd -m -G users,api ec2-user
CMD ["/usr/sbin/start_admin_sshd.sh"]
ENTRYPOINT ["/bin/bash", "-c"]