Commit 780bd7eb authored by  Joe  Rackham's avatar Joe Rackham

Add Gitlab CI section

parent 09c92b00
Pipeline #151848 passed with stage
in 26 seconds
......@@ -26,6 +26,19 @@
\item \texttt{EXPOSE *ports*} - Exposes ports from the container
\item \texttt{CMD []} - Defines the default command to run when the container starts
\end{itemize}
\subsection{Deploying an image}
\begin{itemize}
\item The easiest way to get an image to other devices is to publish it to the registry
\item \texttt{docker push *img\_name*} will push the image, anyone with the name can pull and run it
\end{itemize}
\subsection{Getting an image}
\begin{itemize}
\item \texttt{docker pull *img\_name*} will retrieve an image pushed to the registry
\item Unlike \texttt{git clone}, when you use docker pull you get the code packaged together with the environment and scripts needed to run it.
\end{itemize}
\subsection{Running a container}
\begin{itemize}
\item \texttt{docker run *image\_name*} will create and run a container from an image
......@@ -39,7 +52,74 @@
\item \texttt{-p} - Publishes all exposed ports with the mapping provided
\item \texttt{-P} - Publishes all exposed ports to random port
\end{itemize}
\end{itemize}
\newpage
\section{Gitlab CI}
\subsection{Defining the pipeline}
\begin{itemize}
\item The pipeline should be setup in the .gitlab-ci.yml file
\item jobs are the most fundamental element of the piepline
\begin{itemize}
\item Two elements are required, an arbitrary name and a script clause defining the commands that should be run to constitute the job
\begin{verbatim}
job1:
script: "execute script for job 1"
job2:
script: "execute script for job"
\end{verbatim}
\item If a job constitutes alot of commands it's better to write the in a separate script
\item The `success` of the job is determined by the exit code, if you want the pipeline to fail you need to generate a non zero exit code
\end{itemize}
\item Simmilar jobs can be arranged in stages
\begin{itemize}
\item Jobs within a stage can run in any order but stages will run in the order defined
\begin{verbatim}
stages:
- build
- deploy
job:
stage: build
\end{verbatim}
\end{itemize}
\end{itemize}
\subsection{Dealing with generated output}
\begin{itemize}
\item By default any files generated by a job are discarded after it finishes
\item We can define artifiacts to make these files avaialble afterwards
\begin{verbatim}
job:
artifacts:
paths:
- file1.txt
- file2.txt
expire_in: 1 year
\end{verbatim}
\item By default jobs download all artifacts from previous jobs, we can use dependencies to restrict this
\begin{verbatim}
job:
dependencies:
- file1.txt
- file2.txt
\end{verbatim}
\item Pipeline artifacts are also avaialable after the piepline has finished either from the CI page on Gitlab or at these urls
\begin{itemize}
\item Artifacts from a job on the latest build of a branch \\ https://gitlab.doc.ic.ac.uk/**repourl**/builds/artifacts/**branch**/download?job=**jobname**
\item Artifact for a specific file on the latest build of a branch \\
https://gitlab.doc.ic.ac.uk/**repourl**/builds/artifacts/**branch**/raw/**file**?job=**jobname**
\end{itemize}
\end{itemize}
\newpage
\section{Using these tools together}
\subsection{Using docker with Gitlab CI}
\begin{itemize}
\item Jobs can be configured with the \texttt{image} parameter
\end{itemize}
\end{document}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment