docker
This commit is contained in:
3
DEV1.1/TP12/.dockerignore
Normal file
3
DEV1.1/TP12/.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
*.o
|
||||
app
|
||||
.git
|
||||
12
DEV1.1/TP12/Dockerfile
Normal file
12
DEV1.1/TP12/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM gcc:13 AS build
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN gcc -ansi -pedantic tests.c -o app
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/app .
|
||||
CMD ["./app"]
|
||||
|
||||
# sudo docker build -t app-c
|
||||
# sudo docker run app-c
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
int main(void){
|
||||
int tab[TAILLE_TABLEAU];
|
||||
int tab_inverse[TAILLE_TABLEAU];
|
||||
int i;
|
||||
srand(time(NULL));
|
||||
|
||||
@@ -34,33 +33,6 @@ int main(void){
|
||||
printf("+-----");
|
||||
}
|
||||
printf("+\n");
|
||||
|
||||
/* Remplissage du tableau inverse */
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
tab_inverse[i] = tab[TAILLE_TABLEAU-i-1];
|
||||
}
|
||||
|
||||
/* Affichage du tableau */
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
printf("+-----");
|
||||
}
|
||||
printf("+\n");
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
if (tab_inverse[i] < 10 && tab_inverse[i] >= 0) {
|
||||
printf("| %d ", tab_inverse[i]);
|
||||
}
|
||||
else if (tab_inverse[i] < -9) {
|
||||
printf("| %d ", tab_inverse[i]);
|
||||
}
|
||||
else {
|
||||
printf("| %d ", tab_inverse[i]);
|
||||
}
|
||||
}
|
||||
printf("|\n");
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
printf("+-----");
|
||||
}
|
||||
printf("+\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
42
DEV4.5/TP01_Mise_en_page/01_Chat/v2/activity_main.xml
Normal file
42
DEV4.5/TP01_Mise_en_page/01_Chat/v2/activity_main.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#555"
|
||||
android:padding="10dp"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/champPrincipal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@color/white"
|
||||
android:inputType="textMultiLine" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/champSecondaire"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="bottom"
|
||||
android:layout_toStartOf="@+id/bouton"
|
||||
android:layout_below="@+id/champPrincipal"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bouton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_below="@+id/champPrincipal"
|
||||
android:text="OK"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
43
Docker/Infos.txt
Normal file
43
Docker/Infos.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
---------------------------------------------
|
||||
Dockerfile Java
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
FROM eclipse-temurin:17-jdk
|
||||
|
||||
WORKDIR /Ecriture
|
||||
COPY Ecriture.java .
|
||||
|
||||
RUN javac Ecriture.java
|
||||
|
||||
CMD ["java", "Ecriture"]
|
||||
|
||||
|
||||
---------------------------------------------
|
||||
Commandes
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
Build & run :
|
||||
--------------
|
||||
|
||||
sudo docker build -t appli .
|
||||
sudo docker run --r appli
|
||||
|
||||
Statut docker :
|
||||
----------------
|
||||
|
||||
sudo docker ps (--> Liste l'ensemble des processus dockers en cours, équivalent de ls pour les dockers lancés)
|
||||
|
||||
Accéder aux fichiers du conteneur :
|
||||
-----------------------
|
||||
|
||||
sudo docker exec -it <id_du_conteneur> bash (--> Permet d'accéder aux fichiers du conteneur, on obtient l'id du conteneur avec sudo docker ps)
|
||||
|
||||
|
||||
Créer un volume (monter un dossier de sa machine dans le docker) :
|
||||
------------------------------------------------------------------
|
||||
|
||||
sudo docker run -v $(pwd):/appli nom-image (--> le dossier ":/appli" doit être le nom spécifié dans le Dockerfile, soit WORKDIR /appli)
|
||||
|
||||
|
||||
8
Docker/TP2/Dockerfile
Normal file
8
Docker/TP2/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM eclipse-temurin:17-jdk
|
||||
|
||||
WORKDIR /Ecriture
|
||||
COPY Ecriture.java .
|
||||
|
||||
RUN javac Ecriture.java
|
||||
|
||||
CMD ["java", "Ecriture"]
|
||||
BIN
Docker/TP2/Ecriture.class
Normal file
BIN
Docker/TP2/Ecriture.class
Normal file
Binary file not shown.
48
Docker/TP2/Ecriture.java
Normal file
48
Docker/TP2/Ecriture.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Ecriture {
|
||||
|
||||
|
||||
public static void ecrireFichier() {
|
||||
try {
|
||||
|
||||
BufferedWriter flux = new BufferedWriter(new FileWriter("Texte.txt", true));
|
||||
|
||||
try {
|
||||
|
||||
String aEcrire = "Hello world!";
|
||||
flux.write(aEcrire, 0, aEcrire.length());
|
||||
flux.newLine();
|
||||
|
||||
try {
|
||||
|
||||
flux.close();
|
||||
|
||||
} catch (IOException e3) {
|
||||
System.err.println("Erreur de fermeture.");
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur d'écriture.");
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
System.err.println("Erreur d'ouverture.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
while (true) {
|
||||
Ecriture.ecrireFichier();
|
||||
System.out.println("Fichier modifié.");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e4) {
|
||||
System.err.println("Erreur de timer.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
Docker/TP2/Texte.txt
Normal file
2
Docker/TP2/Texte.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Hello world!
|
||||
Hello world!
|
||||
Reference in New Issue
Block a user