forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-node
88 lines (77 loc) · 2.96 KB
/
Dockerfile-node
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
# syntax=docker/dockerfile:1
# This Dockerfile makes the "build box connect" the container used
# to build the Teleport Connect. It can also be used to build the
# web assets for the Teleport UI.
#
# This image is base on the node image, which is based on Debian Bullseye.
# Using it as an image allows us to link against the oldest version of glibc
# supported by Node.js Docker images.
#
# Check the README to learn how to safely introduce changes to Dockerfiles.
## BUILDBOX-NODE ###################################################################
# Pin the tag to Debian Bullseye to make sure the glibc compatibility
# (glibc version of Bullseye is 2.31).
ARG NODE_VERSION
FROM node:${NODE_VERSION}-bullseye AS buildbox
# BUILDARCH is automatically set by DOCKER when building the image with Build Kit (MacOS by deafult).
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG BUILDARCH
RUN corepack enable pnpm
COPY locale.gen /etc/locale.gen
COPY profile /etc/profile
ENV LANGUAGE="en_US.UTF-8" \
LANG="en_US.UTF-8" \
LC_ALL="en_US.UTF-8" \
LC_CTYPE="en_US.UTF-8" \
DEBIAN_FRONTEND="noninteractive"
# Install packages.
RUN apt-get -y update && \
apt-get install -q -y --no-install-recommends \
build-essential \
ca-certificates \
git \
golang \
libc6-dev \
libssl-dev \
locales \
openssh-client \
pkg-config \
python3-pip \
python3-setuptools \
python3-wheel \
# Used during tag builds to build the RPM package of Connect.
rpm \
&& \
# Manually install the wasm-opt binary from the binaryen package on ARM64.
if [ "$BUILDARCH" = "arm64" ]; then apt-get install -y binaryen; fi && \
dpkg-reconfigure locales && \
apt-get -y clean && \
rm -rf /var/lib/apt/lists/*
# The node image already has a "node" user with UID:GID 1000:1000.
# For consistency with the other images, we are going to remove this user
# (to prevent UID/GID conflicts) and create the typical "ci" user.
# Add the CI user.
RUN userdel -r node
ARG UID
ARG GID
RUN groupadd ci --gid=$GID -o && \
useradd ci --uid=$UID --gid=$GID --create-home --shell=/bin/sh
# Install Rust.
ARG RUST_VERSION
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=$RUST_VERSION
RUN mkdir -p $RUSTUP_HOME && chmod a+w $RUSTUP_HOME && \
mkdir -p $CARGO_HOME/registry && chmod -R a+w $CARGO_HOME
USER ci
RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain $RUST_VERSION && \
rustup --version && \
cargo --version && \
rustc --version && \
rustup component add rustfmt clippy && \
rustup target add wasm32-unknown-unknown && \
if [ "$BUILDARCH" = "amd64" ]; then rustup target add aarch64-unknown-linux-gnu; fi
# Install wasm-pack for targeting WebAssembly from Rust.
ARG WASM_PACK_VERSION
RUN cargo install wasm-pack --locked --version ${WASM_PACK_VERSION}