Skip to content

Commit

Permalink
Merge branch 'master' into sdktechno-238
Browse files Browse the repository at this point in the history
  • Loading branch information
TFellet authored Aug 2, 2023
2 parents 7f272d2 + fb88a06 commit 63c4315
Show file tree
Hide file tree
Showing 20 changed files with 420 additions and 2 deletions.
30 changes: 30 additions & 0 deletions technologies/app/vscode/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,36 @@ contexts:
image: "saagie/vscode-server"
baseTag: "python-4.1.0-10"
version: "python-4.1.0-10-1.159.0"
- id: vscode-4.15.0
label: VS Code 4.15.0
releaseNotes: ""
available: true
trustLevel: experimental
ports:
- port: 80
name: vscode
rewriteUrl: false
basePath: SAAGIE_BASE_PATH
volumes: ["/config/workspace", "/config/data/User"]
dockerInfo:
image: "saagie/vscode-server"
baseTag: "4.15.0"
version: "4.15.0-1.163.0"
- id: vscode-python-4.15.0
label: VS Code Python 4.15.0
releaseNotes: ""
available: true
trustLevel: experimental
ports:
- port: 80
name: vscode
rewriteUrl: false
basePath: SAAGIE_BASE_PATH
volumes: ["/config/workspace", "/config/data/User"]
dockerInfo:
image: "saagie/vscode-server"
baseTag: "python-4.15.0"
version: "python-4.15.0-1.163.0"
- id: vscode-4.8.3
label: VS Code 4.8.3
releaseNotes: ""
Expand Down
117 changes: 117 additions & 0 deletions technologies/app/vscode/vscode-4.15-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
ARG BASE_CONTAINER

FROM saagie/python:3.9-1.109.0 AS PYTHON39
FROM $BASE_CONTAINER

RUN apt-get update \
&& apt-get install -qqy --no-install-recommends \
wget \
gcc \
g++ \
libsasl2-2 \
libsasl2-modules-ldap \
build-essential \
unixodbc \
unixodbc-dev \
libpq-dev \
libsqlite3-dev \
libkrb5-dev \
libsasl2-dev \
libssl-dev \
libcurl4-openssl-dev \
libgeos-dev \
swig \
python3-matplotlib \
python3-lxml \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/

ARG NB_UID="1000"
ARG NB_GID="100"

ENV CONDA_DIR=/opt/conda \
SHELL=/bin/bash \
NB_UID=${NB_UID} \
NB_GID=${NB_GID} \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV PATH="${CONDA_DIR}/bin:${PATH}"

# Install miniforge
ARG CONDA_MIRROR=https://github.com/conda-forge/miniforge/releases/latest/download

# ---- Miniforge installer ----
# Check https://github.com/conda-forge/miniforge/releases
# Package Manager and Python implementation to use (https://github.com/conda-forge/miniforge)
# We're using Mambaforge installer, possible options:
# - conda only: either Miniforge3 to use Python or Miniforge-pypy3 to use PyPy
# - conda + mamba: either Mambaforge to use Python or Mambaforge-pypy3 to use PyPy
# Installation: conda, mamba, pip
RUN set -x && \
# Miniforge installer
miniforge_arch=$(uname -m) && \
miniforge_installer="Mambaforge-Linux-${miniforge_arch}.sh" && \
wget --quiet "${CONDA_MIRROR}/${miniforge_installer}" && \
/bin/bash "${miniforge_installer}" -f -b -p "${CONDA_DIR}" && \
rm "${miniforge_installer}" && \
# Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
conda config --system --set auto_update_conda false && \
conda config --system --set show_channel_urls true && \
if [[ "${PYTHON_VERSION}" != "default" ]]; then mamba install --quiet --yes python="${PYTHON_VERSION}"; fi && \
# Pin major.minor version of python
mamba list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
# Using conda to update all packages: https://github.com/mamba-org/mamba/issues/1092
conda update --all --quiet --yes && \
conda clean --all -f -y && \
fix-permissions "${CONDA_DIR}"

# Create 3 conda envs
RUN conda create -n py38 python=3.8.12 \
&& bash -c "source activate py38 && conda install notebook ipykernel -y && ipython kernel install --user --name py38 --display-name 'Python 3.8'" \
&& conda create -n py39 python=3.9.10 \
&& bash -c "source activate py39 && conda install notebook ipykernel -y && ipython kernel install --user --name py39 --display-name 'Python 3.9'" \
&& conda create -n py310 python=3.10.2 \
&& bash -c "source activate py310 && conda install notebook ipykernel -y && ipython kernel install --user --name py310 --display-name 'Python 3.10'" \
&& conda clean -ay \
&& rm -rf ~/.cache/pip \
&& fix-permissions "${CONDA_DIR}"

# Get requirements from Saagie Python image
COPY --from=PYTHON39 /tmp/requirements.txt /tmp/requirements.txt

SHELL ["/bin/bash", "-c"]

# Install requirements from Saagie Python image
RUN sh -x \
&& for env in py38 py39 py310; \
do \
. activate $env \
&& python -m pip install --no-cache-dir -r /tmp/requirements.txt \
&& conda deactivate; \
done \
&& conda clean -ay \
&& rm -rf ~/.cache/pip \
&& fix-permissions "${CONDA_DIR}"


# Install Vscode Python extension
COPY extensions/* /tmp/extensions/
RUN /app/code-server/bin/code-server --extensions-dir /config/extensions/ --install-extension ms-python.python
RUN /app/code-server/bin/code-server --extensions-dir /config/extensions/ --install-extension genieai.chatgpt-vscode
RUN /app/code-server/bin/code-server --extensions-dir /config/extensions/ --install-extension /tmp/extensions/GitHub.copilot-1.99.290.vsix

# # # Change settings to run interactive code in jupyter
# COPY resources/* /config/data/User/
RUN rm /tmp/settings/settings.json
COPY resources/* /tmp/settings/

ENV CONDA_DEFAULT_ENV=py310

# Setup user env and prefix environment variables with VSCODE_
RUN conda init bash \
&& echo "conda activate py310" >> ~/.bashrc \
&& sed -i '2s|^|\
mkdir -p /config/workspace/.vscode \n \
cp -u /tmp/settings/project-settings.json /config/workspace/.vscode/settings.json \n \
|' /etc/s6-overlay/s6-rc.d/svc-code-server/run
35 changes: 35 additions & 0 deletions technologies/app/vscode/vscode-4.15-python/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2019-2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.bmuschko.gradle.docker.DockerRemoteApiPlugin
import com.saagie.technologies.SaagieTechnologiesGradlePlugin
import com.saagie.technologies.readDockerInfo
import com.saagie.technologies.getVersionForDocker


apply<DockerRemoteApiPlugin>()
apply<SaagieTechnologiesGradlePlugin>()

val dockerInfo = readDockerInfo(projectDir)

tasks.withType(com.bmuschko.gradle.docker.tasks.image.DockerBuildImage::class) {
dependsOn(":vscode-4.15:testImage")
this.buildArgs.put(
"BASE_CONTAINER",
"${dockerInfo?.image}:4.15.0-${this.project.getVersionForDocker()}"
)
}
11 changes: 11 additions & 0 deletions technologies/app/vscode/vscode-4.15-python/context.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: vscode-python-4.15.0
label: VS Code Python 4.15.0
releaseNotes: ""
available: true
trustLevel: experimental
ports:
- port: 80
name: vscode
rewriteUrl: false
basePath: SAAGIE_BASE_PATH
volumes: ["/config/workspace", "/config/data/User"]
4 changes: 4 additions & 0 deletions technologies/app/vscode/vscode-4.15-python/dockerInfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: saagie/vscode-server
baseTag: python-4.15.0
dynamicVersion: 1.163.0_SDKTECHNO-237
version: python-4.15.0-1.163.0
Binary file not shown.
28 changes: 28 additions & 0 deletions technologies/app/vscode/vscode-4.15-python/image_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
schemaVersion: "2.0.0"

metadataTest:
env:
- key: LANG
value: "en_US.UTF-8"
- key: LC_ALL
value: "en_US.UTF-8"
- key: CONDA_DIR
value: "/opt/conda"

fileExistenceTests:
- name: "entrypoint"
path: "/entrypoint.sh"
shouldExist: true
permissions: "-rwxr-xr-x"
- name: "vs code nginx"
path: "/etc/nginx/sites-enabled/nginx.conf"
shouldExist: true
- name: " No default nginx conf"
path: /etc/nginx/sites-enabled/default
shouldExist: false

commandTests:
- name: "python installation"
command: "which"
args: [ "python" ]
expectedOutput: [ "/opt/conda/bin/python" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.defaultInterpreterPath": "/opt/conda/envs/py310/bin/python"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"jupyter.sendSelectionToInteractiveWindow": true,
"jupyter.alwaysScrollOnNewCell": true,
"jupyter.askForKernelRestart": false,
"interactiveWindow.collapseCellInputCode": "never",
"workbench.colorTheme": "Default Dark+"
}
42 changes: 42 additions & 0 deletions technologies/app/vscode/vscode-4.15/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM ghcr.io/linuxserver/code-server:4.15.0

USER root

ENV PUID=1000
ENV PGID=1000
RUN TZ=Europe/London

RUN apt-get update \
&& apt-get install -y nginx \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& rm /etc/nginx/sites-enabled/default

COPY resources/nginx.conf /etc/nginx/sites-enabled/nginx.conf
COPY resources/entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh \
&& chmod +x /etc/nginx/sites-enabled/nginx.conf

# Copy a script that we will use to correct permissions after running certain commands
COPY resources/fix-permissions /usr/local/bin/fix-permissions
RUN chmod a+rx /usr/local/bin/fix-permissions

RUN mkdir -p /tmp/settings
COPY resources/settings.json /tmp/settings/

RUN sed -i 's/SUDO_PASSWORD/VSCODE_SUDO_PASSWORD/g' /etc/s6-overlay/s6-rc.d/init-code-server/run \
&& sed -i '2s|^|\
export PASSWORD=$VSCODE_PASSWORD \n \
export HASHED_PASSWORD=$VSCODE_HASHED_PASSWORD \n \
mkdir -p /config/data/User/ \n \
cp -u /tmp/settings/settings.json /config/data/User/ \n \
fix-permissions /config/ \n \
|' /etc/s6-overlay/s6-rc.d/svc-code-server/run

COPY resources/nginx-run /etc/services.d/nginx/run

EXPOSE 8443

# Use s6-overlay as entrypoint to run multiple processes
ENTRYPOINT ["/init"]
22 changes: 22 additions & 0 deletions technologies/app/vscode/vscode-4.15/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2019-2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.bmuschko.gradle.docker.DockerRemoteApiPlugin
import com.saagie.technologies.SaagieTechnologiesGradlePlugin

apply<DockerRemoteApiPlugin>()
apply<SaagieTechnologiesGradlePlugin>()
11 changes: 11 additions & 0 deletions technologies/app/vscode/vscode-4.15/context.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: vscode-4.15.0
label: VS Code 4.15.0
releaseNotes: ""
available: true
trustLevel: experimental
ports:
- port: 80
name: vscode
rewriteUrl: false
basePath: SAAGIE_BASE_PATH
volumes: ["/config/workspace", "/config/data/User"]
4 changes: 4 additions & 0 deletions technologies/app/vscode/vscode-4.15/dockerInfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: saagie/vscode-server
baseTag: 4.15.0
dynamicVersion: 1.163.0_SDKTECHNO-237
version: 4.15.0-1.163.0
13 changes: 13 additions & 0 deletions technologies/app/vscode/vscode-4.15/image_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
schemaVersion: "2.0.0"

fileExistenceTests:
- name: "entrypoint"
path: "/entrypoint.sh"
shouldExist: true
permissions: "-rwxr-xr-x"
- name: "vs code nginx"
path: "/etc/nginx/sites-enabled/nginx.conf"
shouldExist: true
- name: " No default nginx conf"
path: /etc/nginx/sites-enabled/default
shouldExist: false
14 changes: 14 additions & 0 deletions technologies/app/vscode/vscode-4.15/resources/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
echo "Set Proxy"
export PROXY_DOMAIN=$SAAGIE_BASE_PATH

echo "SAAGIE_BASE_PATH"
echo $SAAGIE_BASE_PATH
echo "PROXY_DOMAIN"
echo $PROXY_DOMAIN

# /init

sed -i 's:SAAGIE_BASE_PATH:'"$SAAGIE_BASE_PATH"':g' /etc/nginx/sites-enabled/nginx.conf

/init
Loading

0 comments on commit 63c4315

Please sign in to comment.