Browse Source

myservices/cloud

master
zeus 1 year ago
parent
commit
893e95ac34
  1. 9
      docs/modules/myservices/nav.adoc
  2. 293
      docs/modules/myservices/pages/c1.adoc
  3. 15
      docs/modules/myservices/pages/overview-cloud.adoc

9
docs/modules/myservices/nav.adoc

@ -14,6 +14,15 @@
** xref:overview-proof_of_concept.adoc[Proof_of_concept]
*** xref:poc-datacollector.adoc[Datacollector]
** xref:overview-cloud.adoc[Cloud_and_Services]
*** xref:c1.adoc[Creating_Docker_Image]
*** xref:c2.adoc[Volumes_Networking]
*** xref:c3.adoc[Multi_Container_Appl]
* xref:docs.adoc[LearningObjects]
* xref:allservices.adoc[MicroserviceDocs]
** xref:overview-labroom.adoc[Labrooms]
*** xref:linux.adoc[Linux]
*** xref:mpi.adoc[MPI]
*** xref:nodevuejs.adoc[Node+Vue]

293
docs/modules/myservices/pages/c1.adoc

@ -0,0 +1,293 @@
= Dockerfile
Swarmlab
:idprefix:
:idseparator: -
:!example-caption:
:!table-caption:
:page-pagination:
:experimental:
This is the area where you we guide you to Create Docker Images
== Example 1: Dockerfile with Alpine, Python, and Numpy
[source,docker]
----
# Use Alpine Linux as the base image
FROM alpine:latest
# Set the working directory for the rest of the commands
WORKDIR /app
# Install Python and Numpy
RUN apk add --no-cache python3 numpy
# Copy the application files into the container
COPY app.py .
# Set the command to run when the container starts
CMD ["python3", "app.py"]
----
Let's break down each of the commands used in this Dockerfile:
* FROM alpine:latest: This sets the base image for the Docker image, in this case Alpine Linux. latest refers to the latest version of the image.
* WORKDIR /app: This sets the working directory to /app. This is where any subsequent commands will be run from.
* RUN apk add --no-cache python3 numpy: This installs Python 3 and Numpy using Alpine's package manager. The --no-cache flag is used to prevent the package manager from caching the packages, which saves space in the Docker image.
* COPY app.py .: This copies the app.py file from the local directory into the container's working directory.
* CMD ["python3", "app.py"]: This sets the command that will be run when the container starts. In this case, it runs the app.py file using Python 3.
TIP: This is a very basic example, but you can customize it further by adding more commands and options, such as setting environment variables using ENV, exposing ports using EXPOSE, or setting labels using LABEL. You can also use ENTRYPOINT to set a default command that can be overridden by the user at runtime.
=== app.py
[source,python]
----
import numpy as np
x = np.array([1, 2, 3])
y = np.array([4, 5, 6])
print("x + y =", x + y)
----
=== Build
To build the Docker image, save the Dockerfile to a directory and run the following command in that directory:
[source,bash]
----
docker build -t mypython .
----
TIP: This is a very simple script that imports Numpy and performs a basic array operation. When you build and run the Docker image, this script will be executed as the command defined in the CMD instruction.
== Example 2: Dockerfile whith TexLive
Dockerfile that installs TexLive, the thesis package, and all the necessary language-specific packages for Greek, English, and German, using the Debian base image
[source,bash]
----
FROM debian:buster
LABEL maintainer="Your Name <youremail@example.com>"
# Set the working directory to /app
WORKDIR /app
# Install TexLive and other necessary packages
RUN apt-get update && \
apt-get install -y texlive-full make git && \
apt-get install -y --no-install-recommends \
texlive-lang-greek \
texlive-lang-english \
texlive-lang-german \
texlive-fonts-extra \
biber \
latexmk && \
rm -rf /var/lib/apt/lists/*
# Clone the thesis template repository
RUN git clone https://github.com/kpantel/ntua-thesis-template.git
# Set the working directory to the cloned repository
WORKDIR /app/ntua-thesis-template
# Build the thesis template PDFs for all languages
RUN make clean && \
make all
# Set the entrypoint to the shell
ENTRYPOINT ["/bin/bash"]
----
This Dockerfile starts with a Debian Buster base image and installs TexLive, the necessary language-specific packages for Greek, English, and German, and other necessary packages like biber and latexmk. It then clones the ntua-thesis-template repository which provides a template for double and doctoral theses, and builds the thesis PDFs for all languages using the make all command.
=== Build
To build the Docker image, save the Dockerfile to a directory and run the following command in that directory:
[source,bash]
----
docker build -t mythesis .
----
This will create a Docker image named mythesis.
=== Run
To run the container, use the following command:
[source,bash]
----
docker run -it --name mythesis-container mythesis
----
=== Run with mount
To run the container, use the following command:
[source,bash]
----
mkdir ./docs
docker run -it --name mythesis-container -v "$(pwd)"/docs:/app mythesis
----
This will start a container with a shell prompt where you can interact with the thesis template and TexLive.
TIP: Note that this Dockerfile is just a basic example, and you may need to customize it further to suit your specific needs. For example, you may need to modify the ENTRYPOINT or CMD instructions to start a different command or script, or add additional packages or configurations as necessary.
=== Add Volume
[source,bash]
----
FROM debian:buster
LABEL maintainer="Your Name <youremail@example.com>"
# Set the working directory to /app
WORKDIR /app
# Install TexLive and other necessary packages
RUN apt-get update && \
apt-get install -y texlive-full make git && \
apt-get install -y --no-install-recommends \
texlive-lang-greek \
texlive-lang-english \
texlive-lang-german \
texlive-fonts-extra \
biber \
latexmk && \
rm -rf /var/lib/apt/lists/*
# Clone the thesis template repository
#RUN git clone https://github.com/kpantel/ntua-thesis-template.git
# Set the working directory to the cloned repository
#WORKDIR /app/ntua-thesis-template
# Clone the Masters/Doctoral Thesis template repository
RUN git clone https://github.com/razueroh/master-doctoral-thesis-template.git
# Set the working directory to the cloned repository
WORKDIR /app/master-doctoral-thesis-template
# Build the thesis template PDFs for all languages
RUN make clean && \
make all
# Create a volume to mount a local directory to the container
#VOLUME ["/app/ntua-thesis-template"]
VOLUME ["/app/master-doctoral-thesis-template"]
# Set the entrypoint to the shell
ENTRYPOINT ["/bin/bash"]
----
=== create volume
To create a volume, you can use the following command:
[source,bash]
----
docker volume create mythesisdata
----
This will create a Docker volume named mythesisdata.
=== run the container and mount the volume
You can then use the following command to run the container and mount the volume:
[source,bash]
----
docker run -it --name mythesis-container -v mythesisdata:/app//app/master-doctoral-thesis-template mythesis
----
This will start a container named mythesis-container with the mythesisdata volume mounted to the /app/ntua-thesis-template directory in the container.
NOTE: Note that when you use a volume to mount a local directory to the container, any changes made to the files in the local directory will also be reflected in the container, and vice versa. This can make it easier to edit and manage the thesis files, as you can use your preferred text editor or IDE on your local machine instead of editing the files directly inside the container.
=== Latex example
Here's an example LaTeX file that includes sample text in Greek, English, and German, with appropriate font settings and language-specific settings:
[source,latex]
----
\documentclass[ 11pt, english, greek, ngerman, singlespacing, %twoside ]{MastersDoctoralThesis}
% Fonts for Greek and German
\usepackage{fontspec}
\newfontfamily\greekfont[Script=Greek,Scale=1.0]{FreeSerif}
\newfontfamily\germanfont[Script=Latin,Language=German,Scale=1.0]{FreeSerif}
\begin{document}
% Greek text
\selectlanguage{greek}
Αυτό είναι ένα κείμενο στα Ελληνικά.
% English text
\selectlanguage{english}
This is a sample text in English.
% German text
\selectlanguage{ngerman}
Dies ist ein Beispieltext auf Deutsch.
\end{document}
----
This LaTeX file uses the babel package to switch between the three languages, and sets the appropriate font settings using the fontspec package. The Greek font is set to FreeSerif with the Script=Greek option, while the German font is set to FreeSerif with the Script=Latin and Language=German options.
To compile this LaTeX file using TexLive, you can save it as example.tex and use the following command:
[source,latex]
----
xelatex example.tex
----
This will produce a PDF file named example.pdf with sample text in Greek, English, and German.
== Video
=== Tex
****
TIP: What is LaTeX?
video::9eLjt5Lrocw[youtube]
****
=== NumPy and Pandas
****
TIP: What is the difference between Numpy and Pandas in Python ?
video::zD9yY-1wRUk[youtube]
****

15
docs/modules/myservices/pages/overview-cloud.adoc

@ -0,0 +1,15 @@
= Cloud and Services
:idprefix:
:idseparator: -
:!example-caption:
:!table-caption:
:page-pagination:
:experimental:
This is the area where you we guide you to use the *Cloud and Service* services.
== Cloud and Services
Services organised in a network with scale
Loading…
Cancel
Save