-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prebuild
88 lines (80 loc) · 4.92 KB
/
Dockerfile.prebuild
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
FROM bitnami/oauth2-proxy:7-debian-11 AS oauth2
FROM highcanfly/secret2sshkey:latest AS secret2sshkey
FROM highcanfly/llvm4msvc:latest AS llvm4msvc
FROM highcanfly/llvm4msvc-x86:latest AS llvm4msvc-x86
FROM codercom/code-server:latest AS coder
FROM ubuntu:jammy
USER 0
ARG NODE_MAJOR="20"
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=Etc/UTC
ARG GOVERSION="1.23.3"
ENV ENTRYPOINTD=/entrypoint.d
ENV BASEDIR=/home/coder
ENV HOME=$BASEDIR
WORKDIR ${BASEDIR}
RUN mkdir -p ${BASEDIR} && sed -ibak 's/:\/root:/:\/home\/coder:/g' /etc/passwd
RUN rm /var/lib/dpkg/info/libc-bin.* \
&& apt-get clean \
&& apt-get update \
&& apt install libc-bin
RUN apt-get update && apt-get install -y ca-certificates curl gnupg sshfs php-cli build-essential dnsutils iputils-ping lld llvm clang git cmake vim sudo dumb-init python3-pip zip unzip musl-dev musl-tools\
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install nodejs -y
COPY --from=oauth2 /opt/bitnami/oauth2-proxy/bin/oauth2-proxy /bin/oauth2-proxy
COPY --from=secret2sshkey /app/secret2sshkey /usr/bin/secret2sshkey
COPY scripts/start.sh /usr/bin/start.sh
COPY scripts/msvc.env /usr/local/bin/msvc.env
COPY scripts/msvc-x86.env /usr/local/bin/msvc-x86.env
COPY scripts/getKubeConfig /usr/local/bin/getKubeConfig
RUN chmod ugo+x /usr/bin/start.sh \
&& chmod ugo+x /usr/local/bin/msvc.env \
&& chmod ugo+x /usr/local/bin/msvc-x86.env \
&& echo ". /usr/local/go/bin/golang.env" >> /etc/profile \
&& echo ". /usr/local/bin/msvc.env" >> /etc/profile
COPY hcf.png /usr/share/img/hcf.png
RUN ln -svf /usr/bin/clang-14 /usr/bin/clang-cl \
&& ln -svf /usr/bin/ld.lld-14 /usr/bin/lld-link
COPY --from=llvm4msvc-x86 /usr/share/msvc /usr/share/msvc
COPY --from=llvm4msvc /usr/share/msvc /usr/share/msvc
RUN curl -fsSL https://go.dev/dl/go${GOVERSION}.linux-$(dpkg --print-architecture).tar.gz | tar -xz && mv go /usr/local/ \
&& sed -ibak 's/:\/usr\/bin:/:\/usr\/bin:\/usr\/local\/go\/bin:/g' /etc/profile
COPY --chmod=744 scripts/golang.env /usr/local/go/bin/golang.env
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" | tee /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-get install -y docker-ce docker-ce-cli containerd.io
RUN curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash - \
&& curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl" \
&& chmod +x kubectl && mv kubectl /usr/local/bin/kubectl
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& ${BASEDIR}/.cargo/bin/rustup target add x86_64-pc-windows-msvc \
&& ${BASEDIR}/.cargo/bin/rustup target add x86_64-unknown-linux-gnu \
&& ${BASEDIR}/.cargo/bin/rustup target add aarch64-unknown-linux-gnu \
&& ${BASEDIR}/.cargo/bin/rustup target add aarch64-unknown-linux-musl \
&& ${BASEDIR}/.cargo/bin/rustup target add x86_64-unknown-linux-musl
ENV CC_x86_64_pc_windows_msvc="clang-cl" \
CXX_x86_64_pc_windows_msvc="clang-cl" \
AR_x86_64_pc_windows_msvc="llvm-lib" \
CL_FLAGS="-Wno-unused-command-line-argument -fuse-ld=lld-link /usr/share/msvc/crt/include /usr/share/msvc/sdk/include/ucrt /usr/share/msvc/sdk/include/um /usr/share/msvc/sdk/include/shared" \
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link" \
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS="-Lnative=/usr/share/msvc/crt/lib/x86_64 -Lnative=/usr/share/msvc/sdk/lib/um/x86_64 -Lnative=/usr/share/msvc/sdk/lib/ucrt/x86_64"
ENV CFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS" \
CXXFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS"
ENV CS_DISABLE_GETTING_STARTED_OVERRIDE=1
# RUN curl https://get.okteto.com -sSfL | sh
RUN /usr/bin/bash -c 'source /usr/local/go/bin/golang.env && /usr/local/go/bin/go install -v golang.org/x/tools/gopls@latest'
RUN /usr/bin/bash -c 'source /usr/local/go/bin/golang.env && /usr/local/go/bin/go install -v github.com/go-delve/delve/cmd/dlv@latest'
RUN /usr/bin/bash -c 'source /usr/local/go/bin/golang.env && /usr/local/go/bin/go install -v honnef.co/go/tools/cmd/staticcheck@latest'
RUN apt dist-upgrade -y && apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
RUN cd /usr/lib/llvm-14/bin/ && ln -svf clang clang-cl
RUN git config --global user.email "hcf@coder" \
&& git config --global user.name "hcf coder"
USER 0
EXPOSE 8080
ENTRYPOINT [ "/usr/bin/start.sh" ]