-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
143 lines (133 loc) · 5.88 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# syntax=docker/dockerfile:1
FROM alpine:3.17
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG BUILDPLATFORM
ARG BUILDOS
ARG BUILDARCH
ARG BUILDVARIANT
RUN set -eu; \
echo "TARGETPLATFORM=$TARGETPLATFORM"; \
echo "TARGETOS=$TARGETOS"; \
echo "TARGETARCH=$TARGETARCH"; \
echo "TARGETVARIANT=$TARGETVARIANT"; \
echo "BUILDPLATFORM=$BUILDPLATFORM"; \
echo "BUILDOS=$BUILDOS"; \
echo "BUILDARCH=$BUILDARCH"; \
echo "BUILDVARIANT=$BUILDVARIANT";
RUN --mount=type=secret,id=GITHUB_TOKEN \
set -eux; \
DEPS='alpine-sdk bash libstdc++ libc6-compat python3'; \
apk add --no-cache $DEPS; \
# Constraint to npm 8, or else npm will fail with 'npm ERR! python is not a valid npm option'. See: https://stackoverflow.com/questions/74522956/python-is-not-a-valid-npm-option and https://jubianchi.github.io/semver-check/#/~8/8
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.15/main npm~8; \
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.17/main nodejs~18; \
# Install kerberos dependencies https://github.com/coder/code-server/issues/6535
apk add --no-cache krb5-dev; \
npm config set python python3; \
# Use 'NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT' to fix node 18.20 and 20.12 making experimental API the default, which breaks builds
# Use '-U_FORTIFY_SOURCE' to fix vsnprintf errors in alpine: https://gitlab.alpinelinux.org/alpine/aports/-/issues/8626
# Use '-DUSE_IPO=OFF -DWHOLE_PROGRAM_OPTIMISATION=OFF' to fix lto-wrapper errors?
( set +x; export GITHUB_TOKEN=$( cat /run/secrets/GITHUB_TOKEN ); set -x; CXXFLAGS='-DNODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT' npm install --global [email protected] --unsafe-perm ); \
# Fix missing dependencies. See: https://github.com/coder/code-server/issues/5530
( cd /usr/local/lib/node_modules/code-server/lib/vscode; set +x; export GITHUB_TOKEN=$( cat /run/secrets/GITHUB_TOKEN ); set -x; CXXFLAGS='-DNODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT' npm install --legacy-peer-deps ); \
code-server --version; \
apk del $DEPS
# Install tools
RUN set -eux; \
apk add --no-cache bash bash-completion ca-certificates curl gnupg git git-lfs github-cli iotop jq less lsblk make nano openssh-client openssl p7zip rsync tree yq
# Install pwsh
# See: https://learn.microsoft.com/en-us/powershell/scripting/install/install-alpine?view=powershell-7.3
RUN set -eux; \
apk add --no-cache \
ca-certificates \
less \
ncurses-terminfo-base \
krb5-libs \
libgcc \
libintl \
libssl1.1 \
libstdc++ \
tzdata \
userspace-rcu \
zlib \
icu-libs \
curl
RUN apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache lttng-ust
RUN set -eux; \
mkdir -p /opt/microsoft/powershell/7; \
curl -sSL https://github.com/PowerShell/PowerShell/releases/download/v7.2.8/powershell-7.2.8-linux-alpine-x64.tar.gz | tar -C /opt/microsoft/powershell/7 -zxf -; \
chmod +x /opt/microsoft/powershell/7/pwsh; \
ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh
# Disable telemetry for powershell 7.0.0 and above and .NET core: https://github.com/PowerShell/PowerShell/issues/16234#issuecomment-942139350
ENV POWERSHELL_CLI_TELEMETRY_OPTOUT=1
ENV POWERSHELL_TELEMETRY_OPTOUT=1
ENV POWERSHELL_UPDATECHECK=Off
ENV POWERSHELL_UPDATECHECK_OPTOUT=1
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV DOTNET_TELEMETRY_OPTOUT=1
ENV COMPlus_EnableDiagnostics=0
RUN pwsh -version
# Install pwsh module(s)
RUN pwsh -c 'Install-Module Pester -Force -Scope AllUsers -MinimumVersion 4.0.0 -MaximumVersion 4.10.1 -ErrorAction Stop'
RUN apk add --no-cache sudo
RUN adduser -u 1000 --gecos '' -D user
RUN echo 'user ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/user
# Install common extensions
USER user
# beautify - code formatter
RUN code-server --install-extension [email protected]
# docker
RUN code-server --install-extension [email protected]
# firefox
RUN code-server --install-extension [email protected]
# git
RUN code-server --install-extension [email protected]
RUN code-server --install-extension [email protected]
# github. Install the latest compatible version
RUN code-server --install-extension github.vscode-pull-request-github
# gitlab
RUN code-server --install-extension [email protected]
# jinja
RUN code-server --install-extension [email protected]
RUN code-server --install-extension [email protected]
# kubernetes
RUN code-server --install-extension [email protected]
# markdown
RUN code-server --install-extension [email protected]
RUN code-server --install-extension [email protected]
# prettier - code formatter
RUN code-server --install-extension [email protected]
# pwsh
RUN code-server --install-extension [email protected]
# svg
RUN code-server --install-extension [email protected]
# terraform
RUN code-server --install-extension [email protected]
# toml
RUN code-server --install-extension [email protected]
# vscode
RUN code-server --install-extension [email protected]
# xml
RUN code-server --install-extension [email protected]
# yaml
RUN code-server --install-extension [email protected]
# Add a default settings.json
USER user
COPY --chown=1000:1000 settings.json /home/user/.local/share/code-server/User/settings.json
# Remove the default code-server config file created when extensions are installed
USER user
RUN rm -fv ~/.config/code-server/config.yaml
# Symlink code to code-server
USER root
RUN ln -sfn /usr/local/bin/code-server /usr/local/bin/code
USER root
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENV LANG=en_US.UTF-8
USER user
WORKDIR /home/user
ENTRYPOINT [ "/docker-entrypoint.sh" ]
CMD [ "--bind-addr=0.0.0.0:8080", "--disable-telemetry", "--disable-update-check" ]