mirror of
https://github.com/newtype256/esgi-devops.git
synced 2025-06-04 18:06:26 +02: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
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";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue