From 997f86761a75c8eac4b94743ca7ad5928c035672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20S=C3=B6derberg?= Date: Mon, 20 Apr 2026 16:34:39 +0200 Subject: [PATCH] slim version --- build/Dockerfile | 103 ++++++++--------------------------------------- main.tf | 21 +++++++++- 2 files changed, 36 insertions(+), 88 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 578e079..58022c6 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,99 +1,30 @@ FROM ubuntu:latest AS base -# Copy Gradle from gradle:latest +# 1. Combine updates and system-level tools to save space +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl jq git sudo vim wget unzip locales \ + build-essential libgmp-dev libffi-dev libnuma-dev zlib1g-dev libtinfo-dev \ + python3 python3-venv python3-tk python-is-python3 \ + default-jdk \ + && rm -rf /var/lib/apt/lists/* + +# 2. Setup Locales +RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG=en_US.utf8 + +# 3. Copy Gradle (This is fine as is) COPY --from=gradle:latest /opt/gradle /opt/gradle ENV GRADLE_HOME=/opt/gradle ENV PATH="${GRADLE_HOME}/bin:${PATH}" -# Update and install dependencies -RUN apt-get -y update -RUN apt-get install -y \ - curl \ - jq \ - git \ - sudo \ - vim \ - wget \ - unzip \ - locales - -# Sets local -RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 -ENV LANG=en_US.utf8 - -FROM base AS python-init - -# Install Python -RUN apt-get install -y \ - python3 \ - python3-pip \ - python3-venv \ - python3-tk \ - python-is-python3 - -# Install Python Packages -RUN pip install \ - requests \ - rich \ - ipykernel \ - --break-system-packages - -FROM python-init AS java-init - -# Install JAVA -RUN apt-get install -y \ - default-jdk \ - openjdk-21-source - -FROM java-init AS scala - -# Install Scala -ARG SCALA_VERSION="3.7.3" -ARG URL="https://github.com/scala/scala3/releases/download/${SCALA_VERSION}/scala3-${SCALA_VERSION}.tar.gz" -ARG SCALA_DIR="/usr/share/scala3-${SCALA_VERSION}" -RUN curl -fsL --show-error ${URL} | tar xfz - -C /usr/share && \ - mv ${SCALA_DIR} /usr/share/scala && \ - chown -R root:root /usr/share/scala && \ - chmod -R 755 /usr/share/scala && \ - ln -s /usr/share/scala/bin/* /usr/local/bin - -FROM scala AS haskell-init - -# Install required C libraries and build tools for Haskell/GHC -RUN apt-get install -y \ - build-essential \ - libgmp-dev \ - libffi-dev \ - libnuma-dev \ - zlib1g-dev \ - libtinfo-dev - -# Install ghcup and Haskell tools globally in /opt -ENV GHCUP_INSTALL_BASE_PREFIX=/opt -ENV PATH="/opt/.ghcup/bin:${PATH}" - -RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ - BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ - BOOTSTRAP_HASKELL_GHC_VERSION=latest \ - BOOTSTRAP_HASKELL_CABAL_VERSION=latest \ - BOOTSTRAP_HASKELL_HLS_VERSION=latest \ - sh - -# Ensure the toolchain is readable and executable by all users -RUN chmod -R a+rX /opt/.ghcup - -FROM haskell-init AS lth - -# Clears apt lists -RUN rm -rf /var/lib/apt/lists/* - -# Adds the default User +# 4. Define the user ARG USER=lth-student RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \ && echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \ && chmod 0440 /etc/sudoers.d/${USER} -# Sets user and work directory USER ${USER} WORKDIR /home/${USER} -ENV PATH="${GRADLE_HOME}/bin:${PATH}" \ No newline at end of file + +# Add local bin paths to PATH now so they work once installed in Home +ENV PATH="/home/${USER}/.ghcup/bin:/home/${USER}/.local/bin:${PATH}" \ No newline at end of file diff --git a/main.tf b/main.tf index 0c02791..d3e56df 100644 --- a/main.tf +++ b/main.tf @@ -31,12 +31,29 @@ resource "coder_agent" "main" { startup_script = <<-EOT set -e - # Prepare user home with default files on first start. + # 1. Standard home init if [ ! -f ~/.init_done ]; then cp -rT /etc/skel ~ + + # 2. Install GHCup & Haskell + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ + BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ + BOOTSTRAP_HASKELL_GHC_VERSION=latest \ + BOOTSTRAP_HASKELL_CABAL_VERSION=latest \ + BOOTSTRAP_HASKELL_HLS_VERSION=latest \ + sh + + # 3. Install Scala + curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs + chmod +x cs + ./cs setup --yes + rm cs + + # 4. Create Python Venv + python3 -m venv ~/.venv + touch ~/.init_done fi - EOT # These environment variables allow you to make Git commits right away after creating a