Skip to content
Snippets Groups Projects
Commit 28ad0d6d authored by fournier's avatar fournier
Browse files

initial commit

parent ad7269c6
Branches main
No related tags found
No related merge requests found
Pipeline #1318 failed
FROM python:3.11.2-slim-bullseye AS base
USER root
# default values
ARG PACK_ROOT="base"
ARG USER=kufair
ARG GNAME=kufair
ARG PASSWD=kufair
ARG UID=1853
ARG GID=1853
# environement variables
ENV PACK_ROOT=${PACK_ROOT}
ENV USER=${USER}
ENV GNAME=${GNAME}
ENV UID=${UID}
ENV GID=${GID}
ENV HOME=/home/${USER}
# create user kufair (1853:1853)
RUN if ! id -u "${USER}" > /dev/null 2>&1; then groupadd -g "${GID}" "${GNAME}" \
&& useradd -m -s /bin/bash -g "${GNAME}" -u "${UID}" "${USER}" \
&& chmod -R 777 /tmp \
&& echo "${USER}:${PASSWD}" | chpasswd \
&& chown -R "${USER}:${GID}" "${HOME}"; fi;
# set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install deps as root
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install software-properties-common -y && \
add-apt-repository -y main && \
apt-get install -y --no-install-recommends \
tini \
build-essential \
wget \
ca-certificates \
openssh-client \
curl \
bzip2 \
locales \
apt-utils \
cmake \
ftp \
g++ \
gcc-multilib \
gfortran \
git \
nano-tiny \
unzip \
jq \
vim-tiny \
astro-all
# clean packages
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get purge --auto-remove -y
# install python related deps
#RUN apt-get update -y \
# && apt-get install -y \
# python3 \
# python3-dev \
# python3-pip
# Copying repo to base
RUN mkdir ${HOME}/base
COPY . ${HOME}/base/
# make sure home is fully accessible
RUN chown -R "${USER}:${GID}" "${HOME}"
# set default workdir
WORKDIR ${HOME}/base
# set SHELL
ENV SHELL=/bin/bash
FROM base AS runner
USER root
# install global deps
RUN ./install-deps.sh
# install user virtual env
USER ${USER}
RUN ./install-venv.sh
RUN ./setup-env.sh
# entrypoint and cmd
ENTRYPOINT ["bash", "-c"]
ONBUILD CMD ["/home/kufair/base/run-wrapper.sh"]
FROM base AS explorer
USER root
# install deps of jupyterlab
RUN wget https://deb.nodesource.com/setup_20.x && \
chmod 550 setup_20.x && \
./setup_20.x && \
apt-get install nodejs && \
apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf setup_20.x && \
update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10 && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
# install micro (optional)
RUN curl https://getmic.ro | bash && \
mv micro /usr/bin
# install global deps
RUN ./install-deps.sh
# install user deps
USER ${USER}
RUN ./install-venv.sh
RUN ./install-jupyterlab.sh
RUN ./setup-env.sh
# Exploration ENV
ENV EXPLORE_WORKDIR=${HOME}
ENV EXPLORE_USER=${USER}
# entrypoint and cmd
ENTRYPOINT ["bash", "-c"]
CMD ["/home/kufair/base/explore-wrapper.sh"]
# scitrace-jupyterlab-debian-astro-bullseye
# scitrace-jupyterlab-python3-11
The base package for Jupyterlab Exploration with python3.11
## OS
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab-p4n.aip.de/workflows/scitrace/base-packages/scitrace-jupyterlab-debian-astro-bullseye.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab-p4n.aip.de/workflows/scitrace/base-packages/scitrace-jupyterlab-debian-astro-bullseye/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Debian bullseye
bashrc 0 → 100644
cred="\033[1;31m"
cgrn="\033[1;32m"
cyel="\033[0;33m"
cblu="\033[1;34m"
cpur="\033[0;35m"
ccya="\033[0;36m"
cnon="\033[0m"
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
shopt -s checkwinsize
function show_git_branch() {
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function get_exit_status() {
es=${?}
if [ ${es} -ne 0 ]; then
echo -e "${cred}${es}${cnon} "
fi
}
ps1_prefix="\u@$(hostname) ${cpur}\w${cnon}"
ps1_suffix="${cblu}\$ ${cnon}"
if [[ $(id -u) -eq 0 ]]; then
ps1_suffix="${cred}# ${cnon} "
fi
export PS1="\$(get_exit_status)${ps1_prefix} ${ccya}\$(show_git_branch)${cnon} ${ps1_suffix}"
alias ..="cd .."
alias cl="clear"
alias env="env | sort"
alias gita="git add"
alias gitd="git diff"
alias gitc="git commit -m"
alias gitl="git log"
alias gitp="git pull"
alias gits="git status"
alias grep="grep --color"
alias lsblk="lsblk -o name,maj:min,ro,rm,type,size,mountpoint,label,uuid,pttype,parttypename,type,vendor,model,serial"
alias p="python"
alias pkl="pkill -9"
which micro >/dev/null 2>&1 && alias mic="micro"
export LS_COLORS=${LS_COLORS}:"di=1;34":"*.txt=1;36":"*.md=0;35"
alias l="ls --color=auto -CF"
alias ll='ls --color=auto -lhF --group-directories-first --sort=extension'
alias la="ls --color=auto -AlF"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# color gcc warning
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
which mic >/dev/null 2>&1 && {
export EDITOR="mic"
}
if [[ -n "${HOME}" && -d "${HOME}" ]]; then
cd "${HOME}"
fi
# load virtual python env
. ${HOME}/env/bin/activate
#!/bin/bash
if [ -d /secrets ]; then
# copy read-only secrets to HOME
cp -rpnv /secrets/. ${HOME}/
# define token_filepath if not yet
if [ -z "${token_filepath}" ]; then
token_filepath="${HOME}/.git-token.json"
fi
# if a git token access file is provided
if [ -f "${token_filepath}" ]; then
# the path to repo
if [ "${PACK_ROOT}" == "base" ]; then
# base packages
git_dir="${HOME}"/base/.git
else
# other packages
git_dir="/tmp/source/.git"
fi
# extract url from repo
url=$(git --git-dir "${git_dir}" remote get-url origin)
# read git access token from secrets
git_access_token=$(jq -Mr ".access_token" "${token_filepath}")
user_name=$(jq -Mr ".user.name" "${token_filepath}")
user_email=$(jq -Mr ".user.email" "${token_filepath}")
# match url
re="(gitlab(-p4n)?.aip.de)(\/|:)(.*)"
if [[ $url =~ $re ]]; then
repo=${BASH_REMATCH[4]}
# update url with access token
url="https://${user_name}:${git_access_token}@gitlab-p4n.aip.de/${repo}"
# reset git url
git --git-dir "${git_dir}" remote set-url origin "${url}"
# tell who you are
git --git-dir "${git_dir}" config --global user.name "${user_name}"
git --git-dir "${git_dir}" config --global user.email "${user_email}"
fi
fi
else
echo "no secrets found"
fi
#!/bin/bash
# before script
"${HOME}/base/copy_secrets.sh"
# main explore script
"${HOME}/base/explore.sh"
# catch status of drun
drun_status=$?
exit ${drun_status}
#!/bin/bash
# missing config
export PATH=$PATH:~/.local/bin/
# activate the python env
. ${HOME}/env/bin/activate
# switch to home
cd /
# run the server on port 8080 (exposed)
export NOTEBOOK_PASSWORD=`python3 -c "from notebook.auth import passwd; print(passwd('scitrace'))"`
jupyter lab --no-browser --port=8080 --ip="0.0.0.0" --PasswordIdentityProvider.hashed_password=${NOTEBOOK_PASSWORD}
# install virtualenv globally
pip3 install --upgrade pip
pip3 install --upgrade virtualenv
#!/bin/bash
# create virtual env
virtualenv --python=python3.11 ${HOME}/env
# activate env
. ${HOME}/env/bin/activate
# update path
PATH=$PATH:~/.local/bin:/${HOME}/.local/bin
# install requirements
pip install --upgrade \
jupyterlab==3.6.3 \
jupyterlab-git \
notebook \
jupyter_contrib_nbextensions \
bokeh
JUPYTER_ENABLE_LAB=yes
#!/bin/bash
# create virtual env
virtualenv --python=python3.11 ${HOME}/env
#!/bin/bash
# before script
"${HOME}/base/copy_secrets.sh"
# main script
"${HOME}/${PACK_ROOT}/drun.sh"
# catch status of drun
drun_status=$?
# make product fully accessible RWX for kufair (1853) group
chmod -R 776 ${HOME}/${PACK_ROOT}/products
exit ${drun_status}
cp bashrc ${HOME}/.bashrc
. ${HOME}/.bashrc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment