mirror of
				https://github.com/newtype256/esgi-devops.git
				synced 2025-11-04 08:30:48 +01:00 
			
		
		
		
	slides: mise à jour, ajout de Docker, CI
This commit is contained in:
		
							parent
							
								
									d9f313da55
								
							
						
					
					
						commit
						9e4191a858
					
				
					 12 changed files with 358 additions and 0 deletions
				
			
		
							
								
								
									
										7
									
								
								illustrations/1_tester/README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								illustrations/1_tester/README.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
(1) Installer `direnv`
 | 
			
		||||
(2) Configurer direnv avec votre shell
 | 
			
		||||
(3) Relancer le shell et se mettre dans le dossier 1_tester
 | 
			
		||||
(4) `direnv allow`
 | 
			
		||||
(5) Assurez vous que ça déclenche une "installation" de dépendances
 | 
			
		||||
(6) Assurez vous que vous avez `pytest` disponible (e.g. `which pytest`)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								illustrations/3_docker/fabriquer-un-docker.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								illustrations/3_docker/fabriquer-un-docker.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
let pkgs = import <nixpkgs> {};
 | 
			
		||||
in
 | 
			
		||||
  {
 | 
			
		||||
    nixDocker = pkgs.dockerTools.pullImage {
 | 
			
		||||
      imageName = "lnl7/nix";
 | 
			
		||||
  finalImageTag = "2.0";
 | 
			
		||||
  imageDigest = "sha256:632268d5fd9ca87169c65353db99be8b4e2eb41833b626e09688f484222e860f";
 | 
			
		||||
  sha256 = "1x00ks05cz89k3wc460i03iyyjr7wlr28krk7znavfy2qx5a0hfd";
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								illustrations/3_docker/redis.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								illustrations/3_docker/redis.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,40 @@
 | 
			
		|||
{ pkgs ? import <nixpkgs> {} }:
 | 
			
		||||
 | 
			
		||||
with pkgs;
 | 
			
		||||
let
 | 
			
		||||
  entrypoint = writeScript "entrypoint.sh" ''
 | 
			
		||||
    #!${stdenv.shell}
 | 
			
		||||
    set -e
 | 
			
		||||
    # allow the container to be started with `--user`
 | 
			
		||||
    if [ "$1" = "redis-server" -a "$(${coreutils}/bin/id -u)" = "0" ]; then
 | 
			
		||||
      chown -R redis .
 | 
			
		||||
      exec ${gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@"
 | 
			
		||||
    fi
 | 
			
		||||
    exec "$@"
 | 
			
		||||
  '';
 | 
			
		||||
in
 | 
			
		||||
dockerTools.buildImage {
 | 
			
		||||
  name = "redis";
 | 
			
		||||
  runAsRoot = ''
 | 
			
		||||
    #!${stdenv.shell}
 | 
			
		||||
    ${dockerTools.shadowSetup}
 | 
			
		||||
    groupadd -r redis
 | 
			
		||||
    useradd -r -g redis -d /data -M redis
 | 
			
		||||
    mkdir /data
 | 
			
		||||
    chown redis:redis /data
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  contents = [ redis ];
 | 
			
		||||
 | 
			
		||||
  config = {
 | 
			
		||||
    Cmd = [ "redis-server" ];
 | 
			
		||||
    Entrypoint = [ entrypoint ];
 | 
			
		||||
    ExposedPorts = {
 | 
			
		||||
      "6379/tcp" = {};
 | 
			
		||||
    };
 | 
			
		||||
    WorkingDir = "/data";
 | 
			
		||||
    Volumes = {
 | 
			
		||||
      "/data" = {};
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								illustrations/3_docker/test-docker-nixos.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								illustrations/3_docker/test-docker-nixos.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
{ pkgs, ... }:
 | 
			
		||||
{
 | 
			
		||||
  # On active Docker.
 | 
			
		||||
  virtualisation.docker.enable = true;
 | 
			
		||||
 | 
			
		||||
  docker-containers.database = {
 | 
			
		||||
    image = "postgres:11-alpine";
 | 
			
		||||
    volumes = [ "postgres-data-example:/var/lib/postgresql/data" ];
 | 
			
		||||
    environment = {
 | 
			
		||||
      POSTGRES_PASSWORD = "secret";
 | 
			
		||||
      POSTGRES_USER = "test";
 | 
			
		||||
      POSTGRES_DATABASE = "esgi";
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								illustrations/4_jenkins/jenkins.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								illustrations/4_jenkins/jenkins.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
{ pkgs, ... }:
 | 
			
		||||
{
 | 
			
		||||
  services.jenkins = {
 | 
			
		||||
    enable = true;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue