\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.