From 2e92596f5dc5ec27e3ef9cb0d1bbf6820354a8de Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sat, 14 Sep 2024 19:22:02 +0200 Subject: [PATCH] added devcontainer setup (#418) * added devcontainer setup * fixed name --- .devcontainer/Dockerfile | 37 +++++++++++++++++++++++++ .devcontainer/devcontainer.json | 24 ++++++++++++++++ .github/workflows/test-devcontainer.yml | 22 +++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/test-devcontainer.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..dc840857 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,37 @@ +ARG BASE_IMAGE=temurin-21-tools-deps-jammy +FROM clojure:${BASE_IMAGE} + +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create the user +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # + # [Optional] Add sudo support. Omit if you don't need to install software after connecting. + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libopenblas-dev lz4 gnupg libgomp1 +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BAC6F0C353D04109 +RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null +RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list +RUN sudo apt update +RUN sudo apt install -y intel-oneapi-mkl +# [Optional] Set the default user. Omit if you want to keep the default as root. +USER $USERNAME +SHELL ["/bin/bash", "-ec"] +ENTRYPOINT ["bash"] + + +# Prepare clojure tools +RUN clojure -Ttools list && \ +clojure -Ttools install io.github.seancorfield/clj-new '{:git/tag "v1.2.404" :git/sha "d4a6508"}' :as clj-new && \ +clojure -Ttools install-latest :lib io.github.seancorfield/deps-new :as new && \ +clojure -Ttools list + +RUN sudo apt-get update && \ + sudo apt-get install -y lsb-release diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..61c7d092 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/scicloj/devcontainer-templates/tree/main/src/basecloj +{ + "name": "Base clojure dev env", + "build": { + "dockerfile": "Dockerfile", + "args": { + "BASE_IMAGE": "temurin-21-tools-deps-jammy", + "USERNAME": "${localEnv:USER}" + } + }, + "remoteUser": "${localEnv:USER}", + "containerUser": "${localEnv:USER}", + "features": { + "ghcr.io/devcontainers/features/git:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "betterthantomorrow.calva" + ] + } + } +} diff --git a/.github/workflows/test-devcontainer.yml b/.github/workflows/test-devcontainer.yml new file mode 100644 index 00000000..8d6580b4 --- /dev/null +++ b/.github/workflows/test-devcontainer.yml @@ -0,0 +1,22 @@ +name: Run tests in devcontainer + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + run-tests: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: run tests + uses: devcontainers/ci@v0.3 + with: + runCmd: bash -c 'scripts/get-data.sh && scripts/run-tests' + push: never + +