Manofem commited on
Commit
9f15759
·
verified ·
1 Parent(s): 2f5cec0

Upload 6 files

Browse files
Dockerfile ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:experimental
2
+
3
+ ARG BASE=debian:12
4
+ FROM scratch AS packages
5
+ COPY release-packages/code-server*.deb /tmp/
6
+
7
+ FROM $BASE
8
+
9
+ RUN apt-get update \
10
+ && apt-get install -y \
11
+ curl \
12
+ dumb-init \
13
+ git \
14
+ git-lfs \
15
+ htop \
16
+ locales \
17
+ lsb-release \
18
+ man-db \
19
+ nano \
20
+ openssh-client \
21
+ procps \
22
+ sudo \
23
+ vim-tiny \
24
+ wget \
25
+ zsh \
26
+ && git lfs install \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ # https://wiki.debian.org/Locale#Manually
30
+ RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen \
31
+ && locale-gen
32
+ ENV LANG=en_US.UTF-8
33
+
34
+ RUN adduser --gecos '' --disabled-password coder \
35
+ && echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
36
+
37
+ RUN ARCH="$(dpkg --print-architecture)" \
38
+ && curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
39
+ && chown root:root /usr/local/bin/fixuid \
40
+ && chmod 4755 /usr/local/bin/fixuid \
41
+ && mkdir -p /etc/fixuid \
42
+ && printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
43
+
44
+ COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
45
+ RUN --mount=from=packages,src=/tmp,dst=/tmp/packages dpkg -i /tmp/packages/code-server*$(dpkg --print-architecture).deb
46
+
47
+ # Allow users to have scripts run on container startup to prepare workspace.
48
+ # https://github.com/coder/code-server/issues/5177
49
+ ENV ENTRYPOINTD=${HOME}/entrypoint.d
50
+
51
+ EXPOSE 8080
52
+ # This way, if someone sets $DOCKER_USER, docker-exec will still work as
53
+ # the uid will remain the same. note: only relevant if -u isn't passed to
54
+ # docker-run.
55
+ USER 1000
56
+ ENV USER=coder
57
+ WORKDIR /home/coder
58
+ ENTRYPOINT ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "."]
Dockerfile.fedora ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:experimental
2
+
3
+ ARG BASE=fedora:39
4
+ FROM scratch AS packages
5
+ COPY release-packages/code-server*.rpm /tmp/
6
+
7
+ FROM $BASE
8
+
9
+ RUN dnf update -y \
10
+ && dnf install -y \
11
+ curl \
12
+ git \
13
+ git-lfs \
14
+ htop \
15
+ nano \
16
+ openssh-clients \
17
+ procps \
18
+ wget \
19
+ zsh \
20
+ dumb-init \
21
+ glibc-langpack-en \
22
+ && rm -rf /var/cache/dnf
23
+ RUN git lfs install
24
+
25
+ ENV LANG=en_US.UTF-8
26
+ RUN echo 'LANG="en_US.UTF-8"' > /etc/locale.conf
27
+
28
+ RUN useradd -u 1000 coder && echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
29
+
30
+ RUN ARCH="$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')" \
31
+ && curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
32
+ && chown root:root /usr/local/bin/fixuid \
33
+ && chmod 4755 /usr/local/bin/fixuid \
34
+ && mkdir -p /etc/fixuid \
35
+ && printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
36
+
37
+ COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
38
+ RUN --mount=from=packages,src=/tmp,dst=/tmp/packages rpm -i /tmp/packages/code-server*$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g').rpm
39
+
40
+ # Allow users to have scripts run on container startup to prepare workspace.
41
+ # https://github.com/coder/code-server/issues/5177
42
+ ENV ENTRYPOINTD=${HOME}/entrypoint.d
43
+
44
+ EXPOSE 8080
45
+ # This way, if someone sets $DOCKER_USER, docker-exec will still work as
46
+ # the uid will remain the same. note: only relevant if -u isn't passed to
47
+ # docker-run.
48
+ USER 1000
49
+ ENV USER=coder
50
+ WORKDIR /home/coder
51
+ ENTRYPOINT ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "."]
Dockerfile.opensuse ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:experimental
2
+
3
+ ARG BASE=opensuse/tumbleweed
4
+ FROM scratch AS packages
5
+ COPY release-packages/code-server*.rpm /tmp/
6
+
7
+ FROM $BASE
8
+
9
+ RUN zypper dup -y \
10
+ && zypper in -y \
11
+ curl \
12
+ git \
13
+ git-lfs \
14
+ htop \
15
+ nano \
16
+ openssh-clients \
17
+ procps \
18
+ wget \
19
+ zsh \
20
+ sudo \
21
+ catatonit \
22
+ && rm -rf /var/cache/zypp /var/cache/zypper
23
+ RUN git lfs install
24
+
25
+ ENV LANG=en_US.UTF-8
26
+ RUN echo 'LANG="en_US.UTF-8"' > /etc/locale.conf
27
+
28
+ RUN useradd -u 1000 coder && echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
29
+
30
+ RUN ARCH="$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')" \
31
+ && curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
32
+ && chown root:root /usr/local/bin/fixuid \
33
+ && chmod 4755 /usr/local/bin/fixuid \
34
+ && mkdir -p /etc/fixuid \
35
+ && printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
36
+
37
+ COPY ci/release-image/entrypoint-catatonit.sh /usr/bin/entrypoint-catatonit.sh
38
+ RUN --mount=from=packages,src=/tmp,dst=/tmp/packages rpm -i /tmp/packages/code-server*$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g').rpm
39
+
40
+ # Allow users to have scripts run on container startup to prepare workspace.
41
+ # https://github.com/coder/code-server/issues/5177
42
+ ENV ENTRYPOINTD=${HOME}/entrypoint.d
43
+
44
+ EXPOSE 8080
45
+ # This way, if someone sets $DOCKER_USER, docker-exec will still work as
46
+ # the uid will remain the same. note: only relevant if -u isn't passed to
47
+ # docker-run.
48
+ USER 1000
49
+ ENV USER=coder
50
+ WORKDIR /home/coder
51
+ ENTRYPOINT ["/usr/bin/entrypoint-catatonit.sh", "--bind-addr", "0.0.0.0:8080", "."]
docker-bake.hcl ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use this file from the top of the repo, with `-f ci/release-image/docker-bake.hcl`
2
+
3
+ # Uses env var VERSION if set;
4
+ # normally, this is set by ci/lib.sh
5
+ variable "VERSION" {
6
+ default = "latest"
7
+ }
8
+
9
+ variable "DOCKER_REGISTRY" {
10
+ default = "docker.io/codercom/code-server"
11
+ }
12
+
13
+ variable "GITHUB_REGISTRY" {
14
+ default = "ghcr.io/coder/code-server"
15
+ }
16
+
17
+ group "default" {
18
+ targets = [
19
+ "code-server-debian-12",
20
+ "code-server-ubuntu-focal",
21
+ "code-server-fedora-39",
22
+ "code-server-opensuse-tumbleweed",
23
+ ]
24
+ }
25
+
26
+ function "prepend_hyphen_if_not_null" {
27
+ params = [tag]
28
+ result = notequal("","${tag}") ? "-${tag}" : "${tag}"
29
+ }
30
+
31
+ # use empty tag (tag="") to generate default tags
32
+ function "gen_tags" {
33
+ params = [registry, tag]
34
+ result = notequal("","${registry}") ? [
35
+ notequal("", "${tag}") ? "${registry}:${tag}" : "${registry}:latest",
36
+ notequal("latest",VERSION) ? "${registry}:${VERSION}${prepend_hyphen_if_not_null(tag)}" : "",
37
+ ] : []
38
+ }
39
+
40
+ # helper function to generate tags for docker registry and github registry.
41
+ # set (DOCKER|GITHUB)_REGISTRY="" to disable corresponding registry
42
+ function "gen_tags_for_docker_and_ghcr" {
43
+ params = [tag]
44
+ result = concat(
45
+ gen_tags("${DOCKER_REGISTRY}", "${tag}"),
46
+ gen_tags("${GITHUB_REGISTRY}", "${tag}"),
47
+ )
48
+ }
49
+
50
+ target "code-server-debian-12" {
51
+ dockerfile = "ci/release-image/Dockerfile"
52
+ tags = concat(
53
+ gen_tags_for_docker_and_ghcr(""),
54
+ gen_tags_for_docker_and_ghcr("debian"),
55
+ gen_tags_for_docker_and_ghcr("bookworm"),
56
+ )
57
+ platforms = ["linux/amd64", "linux/arm64"]
58
+ }
59
+
60
+ target "code-server-ubuntu-focal" {
61
+ dockerfile = "ci/release-image/Dockerfile"
62
+ tags = concat(
63
+ gen_tags_for_docker_and_ghcr("ubuntu"),
64
+ gen_tags_for_docker_and_ghcr("focal"),
65
+ )
66
+ args = {
67
+ BASE = "ubuntu:focal"
68
+ }
69
+ platforms = ["linux/amd64", "linux/arm64"]
70
+ }
71
+
72
+ target "code-server-fedora-39" {
73
+ dockerfile = "ci/release-image/Dockerfile.fedora"
74
+ tags = concat(
75
+ gen_tags_for_docker_and_ghcr("fedora"),
76
+ gen_tags_for_docker_and_ghcr("39"),
77
+ )
78
+ args = {
79
+ BASE = "fedora:39"
80
+ }
81
+ platforms = ["linux/amd64", "linux/arm64"]
82
+ }
83
+
84
+ target "code-server-opensuse-tumbleweed" {
85
+ dockerfile = "ci/release-image/Dockerfile.opensuse"
86
+ tags = concat(
87
+ gen_tags_for_docker_and_ghcr("opensuse"),
88
+ gen_tags_for_docker_and_ghcr("tumbleweed"),
89
+ )
90
+ args = {
91
+ BASE = "opensuse/tumbleweed"
92
+ }
93
+ platforms = ["linux/amd64", "linux/arm64"]
94
+ }
entrypoint-catatonit.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ # We do this first to ensure sudo works below when renaming the user.
5
+ # Otherwise the current container UID may not exist in the passwd database.
6
+ eval "$(fixuid -q)"
7
+
8
+ if [ "${DOCKER_USER-}" ]; then
9
+ USER="$DOCKER_USER"
10
+ if [ "$DOCKER_USER" != "$(whoami)" ]; then
11
+ echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
12
+ # Unfortunately we cannot change $HOME as we cannot move any bind mounts
13
+ # nor can we bind mount $HOME into a new home as that requires a privileged container.
14
+ sudo usermod --login "$DOCKER_USER" coder
15
+ sudo groupmod -n "$DOCKER_USER" coder
16
+
17
+ sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
18
+ fi
19
+ fi
20
+
21
+ # Allow users to have scripts run on container startup to prepare workspace.
22
+ # https://github.com/coder/code-server/issues/5177
23
+ if [ -d "${ENTRYPOINTD}" ]; then
24
+ find "${ENTRYPOINTD}" -type f -executable -print -exec {} \;
25
+ fi
26
+
27
+ exec catatonit -- /usr/bin/code-server "$@"
entrypoint.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ # We do this first to ensure sudo works below when renaming the user.
5
+ # Otherwise the current container UID may not exist in the passwd database.
6
+ eval "$(fixuid -q)"
7
+
8
+ if [ "${DOCKER_USER-}" ]; then
9
+ USER="$DOCKER_USER"
10
+ if [ "$DOCKER_USER" != "$(whoami)" ]; then
11
+ echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
12
+ # Unfortunately we cannot change $HOME as we cannot move any bind mounts
13
+ # nor can we bind mount $HOME into a new home as that requires a privileged container.
14
+ sudo usermod --login "$DOCKER_USER" coder
15
+ sudo groupmod -n "$DOCKER_USER" coder
16
+
17
+ sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
18
+ fi
19
+ fi
20
+
21
+ # Allow users to have scripts run on container startup to prepare workspace.
22
+ # https://github.com/coder/code-server/issues/5177
23
+ if [ -d "${ENTRYPOINTD}" ]; then
24
+ find "${ENTRYPOINTD}" -type f -executable -print -exec {} \;
25
+ fi
26
+
27
+ exec dumb-init /usr/bin/code-server "$@"