Commit 438a2200 authored by Johanna Vaske's avatar Johanna Vaske
Browse files

Add week 2 presentation, resources and LaTeX summary template

parent 7285e6c9
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+24 −0
Original line number Diff line number Diff line
# LaTeX auxiliary files
*.aux
*.log
*.out
*.toc
*.lof
*.lot
*.fls
*.fdb_latexmk
*.synctex.gz
*.bbl
*.blg

# R / RMarkdown
*.Rproj
.Rproj.user/
*.html
*.nb.html

# macOS
.DS_Store

# Figures cache
*/figure/
+31 −4
Original line number Diff line number Diff line
# DataScienceCompass: A Student Guide to R and RStudio
This repository serves as a guide for students in the Module Introduction to Data Science with R and RStudio. 
It contains student presentation materials, summaries, and other helpful resources.
Feel free to contribute :)
# 📘 Students' Guide – Introduction to Data Science with R & RStudio

This repository accompanies the course **"Introduction to Data Science with R and RStudio"** and serves as a central hub for:

- 🎤 Weekly **student presentations**
- 🧾 Lecture **summaries** 
- 🧰 Useful **templates, links, and resources**

---

## 📁 Folder Structure

```bash
StudentsGuide_intro_data_science/
├── student_presentations/        # Weekly presentations (to be added...)
│   ├── week1_tba/                
│   └── week2_installation_docker+docker-compose+git/
│       ├── LaTeX_files/
│       │   ├── setting-up_SSH_Docker_Docker-Compose_Git_on_remote-server.tex
│       │   └── figures/
│       └── presentation.pdf

├── summaries/                    # LaTeX template included
│   └── summary_template.tex

├── ressources/                   # Helpfull links, tips & material (open to expansion)
│   └── README.md

├── .gitignore                    
└── README.md                   

ressources/links.qmd

0 → 100644
+6 −0
Original line number Diff line number Diff line

## Resources

- [Git](https://git-scm.com)
- [Docker](https://www.docker.com)
- [SELinux Repo](https://download.opensuse.org/repositories/security:/SELinux/)
+302 −0
Original line number Diff line number Diff line
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{parskip}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{minted} % Requires shell-escape
\usepackage{xcolor}

\geometry{margin=2.5cm}
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\lhead{Intro to Data Science: Remote Server Setup Guide}

\usepackage{titling}
\pretitle{\begin{center}\LARGE\bfseries}
\posttitle{\par\vspace{1em}\includegraphics[width=0.15\textwidth]{docker-mark-blue.png}\par\end{center}}
\preauthor{\begin{center}\normalsize}
\postauthor{\end{center}}
\predate{\begin{center}\normalsize}
\postdate{\end{center}}

\title{\textbf{To-Do List:\\
Setting Up SSH, Docker, Docker-Compose\\
and Git on your Remote Server}}
\author{}
\date{April 16, 2025}

\begin{document}

\maketitle

\section*{1. Establish SSH Connection:}

\subsection*{Generate SSH Key on Local Laptop (if needed...)}
\begin{minted}[breaklines]{bash}
$ ssh-keygen
\end{minted}
This creates a new SSH key pair (public and private).

\subsection*{Add SSH Key to SSH Agent}
\begin{minted}[breaklines]{bash}
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/ids_student<number>
\end{minted}

\subsection*{Copy Public Key to Server}
\begin{minted}[breaklines]{bash}
$ ssh ids_student<number>@<server_ip>
\end{minted}
Copy and paste the public key into your \texttt{\~/.ssh/config}, as shown last week.

\subsection*{Alternative Approach for Windows Using Git Bash (if needed...)} 
Ensures that Git Bash is set up to handle SSH connections on Windows automatically.

\subsection*{Configure SSH for GitLab Access in \texttt{\~/.bash\_profile}}
\begin{minted}[breaklines]{bash}
# .bash_profile

# Load .bashrc if it exists
if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi

# Start SSH agent if not running
SSH_ENV="$HOME/.ssh/environment"

function start_agent {
    echo "Initializing new SSH agent..."
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo "SSH agent started"
    chmod 600 "${SSH_ENV}"
    source "${SSH_ENV}" > /dev/null
    ssh-add ~/.ssh/ids_student<number>
}

# Source SSH settings if available
if [ -f "${SSH_ENV}" ]; then
    source "${SSH_ENV}" > /dev/null
    ps -p $SSH_AGENT_PID > /dev/null || start_agent
else
    start_agent;
fi
\end{minted}

\subsection*{Connect to the server with:}
\begin{minted}[breaklines]{bash}
$ ssh ids_student<number>@<server_ip>
\end{minted}
\emph{Expected output:} \texttt{You are one lucky user, if you bear the key...}

\section*{2. Install Docker and Docker-Compose on the Server\\
(System-Wide)}

\subsection*{Download OpenSUSE SELinux repository (already installed)}
\begin{minted}[breaklines]{bash}
$ sudo zypper addrepo $opensuse_repo
\end{minted}

\subsection*{Installation via \texttt{sudo}}
\begin{minted}[breaklines]{bash}
$ [sudo] password for root:
$ 12345678
\end{minted}

\subsection*{Install Docker}
\begin{minted}[breaklines]{bash}
$ sudo zypper install docker
$ sudo systemctl start docker
$ sudo usermod -aG docker $USER
$ sudo docker run hello-world
\end{minted}

\subsection*{Install Docker-Compose}
\begin{minted}[breaklines]{bash}
$ sudo zypper install docker-compose
\end{minted}

\section*{3. Install Git on the Server}
\begin{minted}[breaklines]{bash}
$ sudo zypper install git
$ git --version
\end{minted}

\section*{4. Configure and Connect GitLab with SSH Key}

\subsection*{Generate SSH Key on your Remote Server (if needed... )}
\begin{minted}[breaklines]{bash}
$ ssh-keygen
\end{minted}
This creates a new SSH key pair (public and private).\\
Add the public key to your GitLab account.

\subsection*{Configure \texttt{\~/.ssh/config} for GitLab:}
\begin{minted}[breaklines]{text}
Host aidaho_gitlab
    HostName 144.41.15.23
    User git
    IdentityFile ~/.ssh/<private_key>
    Port 30022
    ServerAliveInterval 120
    ServerAliveCountMax 30
\end{minted}

\subsection*{Test SSH Key Connection to GitLab}
\begin{minted}[breaklines]{bash}
$ ssh -T aidaho_gitlab
\end{minted}
\emph{Expected output:} \texttt{Welcome to GitLab, @your\_gitlab\_username!}

\section*{5. Recap Clone and Work with your Git Repositories}
\subsection*{Clone Git Repository from GitLab}
\begin{minted}[breaklines]{bash}
$ git clone aidaho_gitlab:/your_gitlab_username/repository-name.git
\end{minted}

\subsection*{Use Git for Version Control:}
\begin{itemize}[leftmargin=*,label={--}]
  \item To pull the latest changes:
  \begin{minted}[breaklines]{bash}
$ git pull
  \end{minted}
  \item To commit changes:
  \begin{minted}[breaklines]{bash}
$ git commit -m "commit message"
  \end{minted}
  \item To push changes:
  \begin{minted}[breaklines]{bash}
$ git push
  \end{minted}
\end{itemize}

\subsection*{Optional: Configure Git on the Server}
\begin{minted}[breaklines]{bash}
$ git config --global user.name "your_gitlab_username"
$ git config --global user.email "your_email@example.com"
\end{minted}

\newpage
\section*{6. Outlook -- Set Up Docker for the Application (R Environment)}
\begin{itemize}[leftmargin=*,label={--}]
  \item \textbf{Write a Dockerfile:}\\
    This creates a file named \texttt{Dockerfile} in your project directory. 
    \item This file defines your containerized (R, Python etc.) environment. For example:
    \begin{minted}[breaklines]{dockerfile}
# Use an R base image from the Rocker project
FROM rocker/r-base:latest

# Label (optional)
LABEL maintainer="<name>"

# Update and install system dependencies (modify as needed...)
RUN apt-get update && apt-get install -y \
    libxml2-dev libcurl4-openssl-dev libssl-dev \
    && rm -rf /var/lib/apt/lists/*

# Set your working directory inside the container
WORKDIR /app

# Copy your R project files into the container
COPY . /app

# Install R package dependencies as listed in your definded biliothek.txt
# (biliothek.txt is a text file listing required R libraries, one per line)
COPY biliothek.txt /app/
RUN Rscript -e "packages <- readLines('biliothek.txt'); install.packages(packages, repos='https://cloud.r-project.org')"

# Define the command to run your R application (e.g., an R script)
CMD [ "Rscript", "app.R" ]
    \end{minted}
    \textbf{Explanation:}\\
    Your Dockerfile uses the Rocker R base image to provide an R environment. It installs system dependencies and R libraries (specified in the \texttt{biliothek.txt}) and copies your project files into the container. Finally, you can set a default command to run your R script.
    
  \item \textbf{Build the Docker Image:}\\
    Execute:
    \begin{minted}[breaklines]{bash}
$ docker build -t my-r-app .
    \end{minted}
    This command builds your Docker image and tags it as \texttt{my-r-app}.
    
  \item \textbf{Run the Docker Container:}\\
    Execute:
    \begin{minted}[breaklines]{bash}
$ docker run -p 4000:80 my-r-app
    \end{minted}
    This maps port 80 in the container to port 4000 on your host.
\end{itemize}

 \textbf{Explanation:}\\
    The option \texttt{-p 4000:80} in the Docker run command maps port 80 inside the container (where the application listens for incoming HTTP requests) to port 4000 on the host machine, making the application accessible to users via \texttt{localhost:4000} in their web browser.


\newpage
\section*{7. Docker Compose (Brief Outlook)}
\begin{itemize}[leftmargin=*,label={--}]
  \item \textbf{Docker Compose} is a tool to define and run multi-container applications.
  \item It uses a configuration file (\texttt{docker-compose.yml}) to specify services.
  \item It simplifies managing services via the command line.
\end{itemize}

\section*{8. Update and Manage Code with Git}
\begin{itemize}[leftmargin=*,label={--}]
  \item After modifying code or Docker configurations, use:
  \begin{minted}[breaklines]{bash}
$ git add .
$ git commit -m "Update: Docker setup or feature"
$ git push origin branch-name
  \end{minted}
\end{itemize}

\section*{9. Git Miniconda Workaround\\
(Optional if sudo access is not granted)}
\begin{itemize}[leftmargin=*,label={--}]
  \item \textbf{Download and Install Miniconda:}
  \begin{minted}[breaklines]{bash}
$ bash Miniconda3-latest-Linux-x86_64.sh
$ conda init
  \end{minted}
  \item \textbf{Create a New Conda Environment for Git:}
  \begin{minted}[breaklines]{bash}
$ conda create --name mygitenv git
$ conda activate mygitenv
  \end{minted}
  \item Install additional dependencies as needed...
\end{itemize}

\newpage
\section*{General Summary}
\begin{itemize}
  \item \textbf{Git:} \\
    Version control system for tracking changes, collaboration, branching, and merging while maintaining your project's history. \\
  \item \textbf{Docker:} \\
    Packages your application and its dependencies into their own separate containers. Providing consistent environments across development, testing, and production. \\
    Isolates your project to prevent dependency conflicts. \\
  \item \textbf{Docker Compose:} \\
    A tool to define and manage multi-container applications with a single configuration file, simplifying integration and management.
\end{itemize}

\section*{Workflow Overview}
\begin{itemize}
  \item \textbf{SSH Connections:}  
    Establish secure SSH connections using configured key pairs.
  \item \textbf{Docker \& Docker Compose:}  
    Installed system-wide (via \texttt{zypper}), used to containerize and run your application consistently.
  \item \textbf{Git:}  
    Manages your source code, collaboration, and versioning.
\end{itemize}

\bigskip
For more detailed information, visit:
\begin{itemize}
  \item SELinux Repository: \url{https://download.opensuse.org/repositories/security:/SELinux/}
  \item Git: \url{https://git-scm.com}
  \item Docker: \url{https://www.docker.com}
\end{itemize}

\end{document}
Loading