SlideShare una empresa de Scribd logo
1 de 52
Descargar para leer sin conexión
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
$ docker pull debian:buster
buster: Pulling from library/debian
57df1a1f1ad8: Pull complete
Digest: sha256:f744ed553780b84bf376fbfe7879de9a3aece6e611af110f95ca26188cf85cb6
Status: Downloaded newer image for debian:buster
$ docker run -it debian:buster /bin/bash
$ apt-get update
$ apt-get install -y mono-runtime
$ mono --version
Mono JIT compiler version 5.18.0.240 (Debian 5.18.0.240+dfsg-3 Wed Apr 17 16:37:36 UTC 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
$ which mono
/usr/bin/mono
•
•
FROM debian:buster
RUN apt-get update
RUN apt-get install -y mono-runtime
$ docker build . -t mymono:latest
$ docker run -it mymono:latest /bin/bash
$ mono --version
Mono JIT compiler version 5.18.0.240 (Debian 5.18.0.240+dfsg-3 Wed Apr 17
16:37:36 UTC 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-
project.com
FROM debian:buster
RUN apt-get update
RUN apt-get install -y nginx
ADD nginx.conf /etc
ADD index.html /var/www
CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx.conf"]
EXPOSE 80/tcp
$ docker build . -t mynginx:latest
$ docker run -it -p 8080:80 mynginx:latest
$ docker history mynginx:latest
IMAGE CREATED CREATED BY SIZE COMMENT
029491c6130e 13 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0B
ec94316b9ca2 13 minutes ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B
0bb364d192db 13 minutes ago /bin/sh -c #(nop) ADD file:18aed37573327bee1… 129B
968ebde5fb5d 13 minutes ago /bin/sh -c #(nop) ADD file:f18afd18cfe2728b3… 189B
2c29120ff52b 13 minutes ago /bin/sh -c apt-get install -y nginx 64.2MB
c4974fb27d9a 28 minutes ago /bin/sh -c apt-get update 17.5MB
f6dcff9b59af 4 days ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 4 days ago /bin/sh -c #(nop) ADD file:07a6578d6f507bd9c… 114MB
•
FROM debian:buster
RUN apt-get update
RUN apt-get install -y apache2
ADD index.html /var/www/html
CMD ["apachectl", "-D", "FOREGROUND"]
EXPOSE 80/tcp
$ docker history mynginx:latest
IMAGE CREATED CREATED BY SIZE COMMENT
029491c6130e 13 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp
0B
ec94316b9ca2 13 minutes ago /bin/sh -c #(nop) CMD ["nginx" "-
g" "daemon… 0B
0bb364d192db 13 minutes ago /bin/sh -c #(nop) ADD
file:18aed37573327bee1… 129B
968ebde5fb5d 13 minutes ago /bin/sh -c #(nop) ADD
file:f18afd18cfe2728b3… 189B
2c29120ff52b 13 minutes ago /bin/sh -c apt-get install -y
nginx 64.2MB
c4974fb27d9a 28 minutes ago /bin/sh -c apt-get update 17.5MB
f6dcff9b59af 4 days ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 4 days ago /bin/sh -c #(nop) ADD
file:07a6578d6f507bd9c… 114MB
$ docker history myapache:latest
IMAGE CREATED CREATED BY SIZE COMMENT
fc06c36e1d8b 7 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0B
d456baddadf5 7 minutes ago /bin/sh -c #(nop) CMD ["apachectl" "-D"
"FO… 0B
f4bbb25d31af 7 minutes ago /bin/sh -c #(nop) ADD
file:18aed37573327bee1… 129B
f7afa94e16b4 7 minutes ago /bin/sh -c apt-get install -y apache2
112MB
c4974fb27d9a 39 minutes ago /bin/sh -c apt-get update 17.5MB
f6dcff9b59af 4 days ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 4 days ago /bin/sh -c #(nop) ADD file:07a6578d6f507bd9c…
114MB
•
•
•
•
•
•
#!/bin/bash -e
export MONO_VERSION=5.20.1.27
wget https://download.mono-project.com/sources/mono/mono-$MONO_VERSION.tar.bz2
tar xfv mono-$MONO_VERSION.tar.bz2
cd mono-*
./autogen.sh --prefix=/app/mono --enable-minimal=aot,profiler,debug,logging 
--disable-libraries --disable-boehm --with-mcs-docs=no --with-profile2=no
make
make install
tar cfvz /out/mono-binary-tarball-$MONO_VERSION.tar.bz2 /app/mono
•
•
FROM debian:jessie
RUN apt-get update
RUN apt-get -y install wget gcc g++ bzip2 make autoconf automake libtool 
cmake python pkg-config libglib2.0-dev libcairo2-dev libpng-dev libjpeg-dev libgif-dev
ADD ./build /
CMD /build
$ docker build -t monobuildimage .
$ docker run -v $(pwd)/out:/out --rm -t monobuildimage
$ ls -lh out
total 77M
-rw-r--r-- 1 root root 77M sep 14 23:15 mono-binary-tarball-5.20.1.27.tar.bz2
•
•
•
•
•
•
•
•
•
•
{stdenv, fetchurl, libgdiplus, pkgconfig, gettext, perl, xlibs, zlib}:
stdenv.mkDerivation rec {
name = "mono-${version}";
version = "3.10.0";
src = fetchurl {
url = "http://download.mono-project.com/sources/mono/${name}.tar.bz2";
sha256 = "1d5hib0qsmh3673k3rdd199633lmczdgpbxl6d3rnb8dh6kd2x7x";
};
buildInputs = [ pkgconfig gettext perl libgdiplus xlibs.libX11 zlib ];
NIX_LDFLAGS = "-lgcc_s" ;
dontDisableStatic = true; # To overcome the bug https://bugzilla.novell.com/show_bug.cgi?id=644723
dontStrip = true; # Fix: file /nix/store/xxx-mono-2.4.2.1/lib/mscorlib.dll is an invalid CIL image
# Fix mono DLLMap so it can find libX11 and gdiplus to run winforms apps
postBuild = ''
find . -name 'config' -type f | while read i; do
sed -i "s@libX11.so.6@${xlibs.libX11}/lib/libX11.so.6@g" $i
sed -i '2 i<dllmap dll="gdiplus.dll" target="${libgdiplus}/lib/libgdiplus.so" os="!windows"/>' $i
done
'';
}
rec {
stdenv = ...
fetchurl = ...
xlibs = ...
gettext = ...
perl = ...
pkgconfig = import ./pkgconfig { ... };
libgdiplus = import ./libgdiplus { ... };
zlib = import ./zlib {
inherit stdenv fetchurl;
}
mono = import ./mono {
inherit stdenv fetchurl libgdiplus pkgconfig gettext perl xlibs zlib;
};
...
}
$ nix-build pkgs.nix -A mono
/nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
$ ls -l result
lrwxrwxrwx 1 sbu sbu 55 sep 16 12:07 result ->
/nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
$ ./result/bin/mono --version
Mono JIT compiler version 3.10.0 (tarball Tue Sep 15 08:29:10 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-
project.com
•
•
•
•
•
•
/nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
•
•
/nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
/nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
•
•
•
•
•
•
•
•
•
•
$ nix-store --query --graph $(nix-instantiate pkgs.nix -A mono) > out.dot
$ dot -Tsvg out.dot > out.svg
•
•
$ nix-store -qR result
/nix/store/x76l1l04vnhw82hv6iwcvcchp3f51304-linux-headers-3.7.1
/nix/store/ikc9iziqc2rldacnbb2cdh7bdc1b2c3n-glibc-2.19
/nix/store/iyxa3l0knar229j4mbhn6a7mspp9nymd-zlib-1.2.8
...
/nix/store/whmb7k2f5xiykd3i0g26jzm16cia4s86-giflib-5.0.5
/nix/store/673zzsana5dlry0l22gwdjvyf1k30hw3-libgdiplus-2.10.9
/nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
$ readelf -d ./result/bin/mono
Dynamic section at offset 0x3784b0 contains 32 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [librt.so.1]
0x0000000000000001 (NEEDED) Shared library: [libdl.so.2]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [/nix/store/ygqw3h96jg0h77r2kb6ac98caw1mchh4-gcc-4.8.3/lib/../lib64:/nix/store/ikc9iziqc2rldacnbb2cdh7bdc1b2c3n-glibc-
2.19/lib]
0x000000000000001d (RUNPATH) Library runpath: [/nix/store/ygqw3h96jg0h77r2kb6ac98caw1mchh4-gcc-4.8.3/lib/../lib64:/nix/store/ikc9iziqc2rldacnbb2cdh7bdc1b2c3n-glibc-
2.19/lib]
...
$ python --version
Python 2.7.17
$ which python
/usr/bin/python
$ nix-shell -p python3
$ python --version
Python 3.8.3
$ which python
/nix/store/f87w21b91cws0wbsvyfn5vnlyv491czi-python3-3.8.3/bin/python
•
•
•
•
•
•
•
FROM nixos/nix
RUN nix-channel --add https://nixos.org/channels/nixpkgs-
unstable nixpkgs
RUN nix-channel --update
RUN nix-env -f '<nixpkgs>' -iA nginx
RUN mkdir -p /var/log/nginx /var/cache/nginx /var/www
ADD nginx.conf /etc
ADD index.html /var/www
CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx.conf"]
EXPOSE 80/tcp
•
•
•
with import <nixpkgs> {};
dockerTools.buildImage {
name = "nginxexp";
tag = "test";
contents = nginx;
runAsRoot = ''
${dockerTools.shadowSetup}
groupadd -r nogroup
useradd -r nobody -g nogroup -d /dev/null
mkdir -p /var/log/nginx /var/cache/nginx /var/www
cp ${./index.html} /var/www/index.html
'';
config = {
Cmd = [ "${nginx}/bin/nginx" "-g" "daemon off;" "-c" ./nginx.conf ];
Expose = {
"80/tcp" = {};
};
};
}
•
•
•
$ nix-build
/nix/store/qx9cpvdxj78d98rwfk6a5z2qsmqvgzvk-docker-image-nginxexp.tar.gz
$ docker load -i result
d8847b6d0466: Loading layer
[==================================================>] 62.19MB/62.19MB
Loaded image: nginxexp:test
$ docker run -it -p 8080:80 nginxexp:test
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mynginx latest 029491c6130e 14 hours ago 196MB
nginxexp test cde8298f025f 50 years ago 61MB
•
•
•
•
•
with import <nixpkgs> {};
dockerTools.buildLayeredImage {
name = "nginxexp";
tag = "test";
contents = nginx;
maxLayers = 100;
extraCommands = ''
mkdir -p var/log/nginx var/cache/nginx var/www
cp ${./index.html} var/www/index.html
‘’;
config = {
Cmd = [ "${nginx}/bin/nginx" "-g" "daemon off;" "-c" ./nginx-root.conf ];
Expose = {
"80/tcp" = {};
};
};
}
$ docker history nginxexp:test
IMAGE CREATED CREATED BY SIZE COMMENT
b91799a04b99 50 years ago 1.47kB store paths: ['/nix/store/snxpdsksd4wxcn3niiyck0fry3wzri96-nginxexp-customisation-layer']
<missing> 50 years ago 200B store paths: ['/nix/store/6npz42nl2hhsrs98bq45aqkqsndpwvp1-nginx-root.conf']
<missing> 50 years ago 1.79MB store paths: ['/nix/store/qsq6ni4lxd8i4g9g4dvh3y7v1f43fqsp-nginx-1.18.0']
<missing> 50 years ago 492kB store paths: ['/nix/store/kdrdxhswaqm4dgdqs1vs2l4b4md7djma-pcre-8.44']
<missing> 50 years ago 4.17MB store paths: ['/nix/store/6glpgx3pypxzb09wxdqyagv33rrj03qp-openssl-1.1.1g']
...
<missing> 50 years ago 123kB store paths: ['/nix/store/5x6l9xm5dp6v113dpfv673qvhwjyb7p5-zlib-1.2.11']
<missing> 50 years ago 30.9MB store paths: ['/nix/store/bqbg6hb2jsl3kvf6jgmgfdqy06fpjrrn-glibc-2.30']
<missing> 50 years ago 209kB store paths: ['/nix/store/fhg84pzckx2igmcsvg92x1wpvl1dmybf-libidn2-2.3.0']
<missing> 50 years ago 1.63MB store paths: ['/nix/store/y8n2b9nwjrgfx3kvi3vywvfib2cw5xa6-libunistring-0.9.10']
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計
 
CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015
 
Delivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerDelivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and Docker
 
QNAP COSCUP Container Station
QNAP COSCUP Container StationQNAP COSCUP Container Station
QNAP COSCUP Container Station
 
Advanced Task Scheduling with Amazon ECS (June 2017)
Advanced Task Scheduling with Amazon ECS (June 2017)Advanced Task Scheduling with Amazon ECS (June 2017)
Advanced Task Scheduling with Amazon ECS (June 2017)
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Consuming Cinder from Docker
Consuming Cinder from DockerConsuming Cinder from Docker
Consuming Cinder from Docker
 
15 kubernetes failure points you should watch
15 kubernetes failure points you should watch15 kubernetes failure points you should watch
15 kubernetes failure points you should watch
 
Building a Docker v1.12 Swarm cluster on ARM
Building a Docker v1.12 Swarm cluster on ARMBuilding a Docker v1.12 Swarm cluster on ARM
Building a Docker v1.12 Swarm cluster on ARM
 
Breaking the RpiDocker challenge
Breaking the RpiDocker challenge Breaking the RpiDocker challenge
Breaking the RpiDocker challenge
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)
 
Docker composeで開発環境をメンバに配布せよ
Docker composeで開発環境をメンバに配布せよDocker composeで開発環境をメンバに配布せよ
Docker composeで開発環境をメンバに配布せよ
 
Docker up and running
Docker up and runningDocker up and running
Docker up and running
 
Enjoying k8s cluster with Minikube and Helm
Enjoying k8s cluster with Minikube and HelmEnjoying k8s cluster with Minikube and Helm
Enjoying k8s cluster with Minikube and Helm
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
 
What Have Syscalls Done for you Lately?
What Have Syscalls Done for you Lately?What Have Syscalls Done for you Lately?
What Have Syscalls Done for you Lately?
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
 
Paris container day june17
Paris container day   june17Paris container day   june17
Paris container day june17
 

Similar a Using Nix and Docker as automated deployment solutions

2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 

Similar a Using Nix and Docker as automated deployment solutions (20)

Scaling Development Environments with Docker
Scaling Development Environments with DockerScaling Development Environments with Docker
Scaling Development Environments with Docker
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK Seminar
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
Docker as an every day work tool
Docker as an every day work toolDocker as an every day work tool
Docker as an every day work tool
 
AtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration trainingAtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration training
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
 
Docker practice
Docker practiceDocker practice
Docker practice
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
DeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to DockerDeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to Docker
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)
 
Builder and BuildKit
Builder and BuildKitBuilder and BuildKit
Builder and BuildKit
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to Production
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
 
AWS re:Invent 2016: Amazon ECR Deep Dive on Image Optimization (CON401)
AWS re:Invent 2016: Amazon ECR Deep Dive on Image Optimization (CON401)AWS re:Invent 2016: Amazon ECR Deep Dive on Image Optimization (CON401)
AWS re:Invent 2016: Amazon ECR Deep Dive on Image Optimization (CON401)
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 

Más de Sander van der Burg

Más de Sander van der Burg (20)

The Monitoring Playground
The Monitoring PlaygroundThe Monitoring Playground
The Monitoring Playground
 
Dysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deploymentDysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deployment
 
The NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelyThe NixOS project and deploying systems declaratively
The NixOS project and deploying systems declaratively
 
Deploying (micro)services with Disnix
Deploying (micro)services with DisnixDeploying (micro)services with Disnix
Deploying (micro)services with Disnix
 
Hydra: Continuous Integration and Testing for Demanding People: The Details
Hydra: Continuous Integration and Testing for Demanding People: The DetailsHydra: Continuous Integration and Testing for Demanding People: The Details
Hydra: Continuous Integration and Testing for Demanding People: The Details
 
Hydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The BasicsHydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The Basics
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
 
The Nix project
The Nix projectThe Nix project
The Nix project
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
 
Techniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processesTechniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processes
 
The Nix project
The Nix projectThe Nix project
The Nix project
 
A Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsA Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software Components
 
Deploying .NET services with Disnix
Deploying .NET services with DisnixDeploying .NET services with Disnix
Deploying .NET services with Disnix
 
A Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented SystemsA Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented Systems
 
Using NixOS for declarative deployment and testing
Using NixOS for declarative deployment and testingUsing NixOS for declarative deployment and testing
Using NixOS for declarative deployment and testing
 
Pull Deployment of Services
Pull Deployment of ServicesPull Deployment of Services
Pull Deployment of Services
 
Disnix: A toolset for distributed deployment
Disnix: A toolset for distributed deploymentDisnix: A toolset for distributed deployment
Disnix: A toolset for distributed deployment
 
Automated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented SystemAutomated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented System
 
Deploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package manager
 
Pull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and ChallengesPull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and Challenges
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

Using Nix and Docker as automated deployment solutions

  • 1.
  • 2.
  • 3.
  • 5.
  • 6.
  • 7.
  • 8.
  • 12. $ docker pull debian:buster buster: Pulling from library/debian 57df1a1f1ad8: Pull complete Digest: sha256:f744ed553780b84bf376fbfe7879de9a3aece6e611af110f95ca26188cf85cb6 Status: Downloaded newer image for debian:buster $ docker run -it debian:buster /bin/bash $ apt-get update $ apt-get install -y mono-runtime $ mono --version Mono JIT compiler version 5.18.0.240 (Debian 5.18.0.240+dfsg-3 Wed Apr 17 16:37:36 UTC 2019) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com $ which mono /usr/bin/mono
  • 13. • • FROM debian:buster RUN apt-get update RUN apt-get install -y mono-runtime
  • 14. $ docker build . -t mymono:latest $ docker run -it mymono:latest /bin/bash $ mono --version Mono JIT compiler version 5.18.0.240 (Debian 5.18.0.240+dfsg-3 Wed Apr 17 16:37:36 UTC 2019) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono- project.com
  • 15. FROM debian:buster RUN apt-get update RUN apt-get install -y nginx ADD nginx.conf /etc ADD index.html /var/www CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx.conf"] EXPOSE 80/tcp $ docker build . -t mynginx:latest $ docker run -it -p 8080:80 mynginx:latest
  • 16. $ docker history mynginx:latest IMAGE CREATED CREATED BY SIZE COMMENT 029491c6130e 13 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0B ec94316b9ca2 13 minutes ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B 0bb364d192db 13 minutes ago /bin/sh -c #(nop) ADD file:18aed37573327bee1… 129B 968ebde5fb5d 13 minutes ago /bin/sh -c #(nop) ADD file:f18afd18cfe2728b3… 189B 2c29120ff52b 13 minutes ago /bin/sh -c apt-get install -y nginx 64.2MB c4974fb27d9a 28 minutes ago /bin/sh -c apt-get update 17.5MB f6dcff9b59af 4 days ago /bin/sh -c #(nop) CMD ["bash"] 0B <missing> 4 days ago /bin/sh -c #(nop) ADD file:07a6578d6f507bd9c… 114MB
  • 17. • FROM debian:buster RUN apt-get update RUN apt-get install -y apache2 ADD index.html /var/www/html CMD ["apachectl", "-D", "FOREGROUND"] EXPOSE 80/tcp
  • 18. $ docker history mynginx:latest IMAGE CREATED CREATED BY SIZE COMMENT 029491c6130e 13 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0B ec94316b9ca2 13 minutes ago /bin/sh -c #(nop) CMD ["nginx" "- g" "daemon… 0B 0bb364d192db 13 minutes ago /bin/sh -c #(nop) ADD file:18aed37573327bee1… 129B 968ebde5fb5d 13 minutes ago /bin/sh -c #(nop) ADD file:f18afd18cfe2728b3… 189B 2c29120ff52b 13 minutes ago /bin/sh -c apt-get install -y nginx 64.2MB c4974fb27d9a 28 minutes ago /bin/sh -c apt-get update 17.5MB f6dcff9b59af 4 days ago /bin/sh -c #(nop) CMD ["bash"] 0B <missing> 4 days ago /bin/sh -c #(nop) ADD file:07a6578d6f507bd9c… 114MB $ docker history myapache:latest IMAGE CREATED CREATED BY SIZE COMMENT fc06c36e1d8b 7 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0B d456baddadf5 7 minutes ago /bin/sh -c #(nop) CMD ["apachectl" "-D" "FO… 0B f4bbb25d31af 7 minutes ago /bin/sh -c #(nop) ADD file:18aed37573327bee1… 129B f7afa94e16b4 7 minutes ago /bin/sh -c apt-get install -y apache2 112MB c4974fb27d9a 39 minutes ago /bin/sh -c apt-get update 17.5MB f6dcff9b59af 4 days ago /bin/sh -c #(nop) CMD ["bash"] 0B <missing> 4 days ago /bin/sh -c #(nop) ADD file:07a6578d6f507bd9c… 114MB
  • 21. #!/bin/bash -e export MONO_VERSION=5.20.1.27 wget https://download.mono-project.com/sources/mono/mono-$MONO_VERSION.tar.bz2 tar xfv mono-$MONO_VERSION.tar.bz2 cd mono-* ./autogen.sh --prefix=/app/mono --enable-minimal=aot,profiler,debug,logging --disable-libraries --disable-boehm --with-mcs-docs=no --with-profile2=no make make install tar cfvz /out/mono-binary-tarball-$MONO_VERSION.tar.bz2 /app/mono
  • 22. • • FROM debian:jessie RUN apt-get update RUN apt-get -y install wget gcc g++ bzip2 make autoconf automake libtool cmake python pkg-config libglib2.0-dev libcairo2-dev libpng-dev libjpeg-dev libgif-dev ADD ./build / CMD /build
  • 23. $ docker build -t monobuildimage . $ docker run -v $(pwd)/out:/out --rm -t monobuildimage $ ls -lh out total 77M -rw-r--r-- 1 root root 77M sep 14 23:15 mono-binary-tarball-5.20.1.27.tar.bz2
  • 26.
  • 28. {stdenv, fetchurl, libgdiplus, pkgconfig, gettext, perl, xlibs, zlib}: stdenv.mkDerivation rec { name = "mono-${version}"; version = "3.10.0"; src = fetchurl { url = "http://download.mono-project.com/sources/mono/${name}.tar.bz2"; sha256 = "1d5hib0qsmh3673k3rdd199633lmczdgpbxl6d3rnb8dh6kd2x7x"; }; buildInputs = [ pkgconfig gettext perl libgdiplus xlibs.libX11 zlib ]; NIX_LDFLAGS = "-lgcc_s" ; dontDisableStatic = true; # To overcome the bug https://bugzilla.novell.com/show_bug.cgi?id=644723 dontStrip = true; # Fix: file /nix/store/xxx-mono-2.4.2.1/lib/mscorlib.dll is an invalid CIL image # Fix mono DLLMap so it can find libX11 and gdiplus to run winforms apps postBuild = '' find . -name 'config' -type f | while read i; do sed -i "s@libX11.so.6@${xlibs.libX11}/lib/libX11.so.6@g" $i sed -i '2 i<dllmap dll="gdiplus.dll" target="${libgdiplus}/lib/libgdiplus.so" os="!windows"/>' $i done ''; }
  • 29. rec { stdenv = ... fetchurl = ... xlibs = ... gettext = ... perl = ... pkgconfig = import ./pkgconfig { ... }; libgdiplus = import ./libgdiplus { ... }; zlib = import ./zlib { inherit stdenv fetchurl; } mono = import ./mono { inherit stdenv fetchurl libgdiplus pkgconfig gettext perl xlibs zlib; }; ... }
  • 30. $ nix-build pkgs.nix -A mono /nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0 $ ls -l result lrwxrwxrwx 1 sbu sbu 55 sep 16 12:07 result -> /nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0 $ ./result/bin/mono --version Mono JIT compiler version 3.10.0 (tarball Tue Sep 15 08:29:10 UTC 2020) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono- project.com
  • 35. $ nix-store --query --graph $(nix-instantiate pkgs.nix -A mono) > out.dot $ dot -Tsvg out.dot > out.svg
  • 36. • • $ nix-store -qR result /nix/store/x76l1l04vnhw82hv6iwcvcchp3f51304-linux-headers-3.7.1 /nix/store/ikc9iziqc2rldacnbb2cdh7bdc1b2c3n-glibc-2.19 /nix/store/iyxa3l0knar229j4mbhn6a7mspp9nymd-zlib-1.2.8 ... /nix/store/whmb7k2f5xiykd3i0g26jzm16cia4s86-giflib-5.0.5 /nix/store/673zzsana5dlry0l22gwdjvyf1k30hw3-libgdiplus-2.10.9 /nix/store/0fkqp394m1pfzvjcrn4jisi0sm5c0q8n-mono-3.10.0
  • 37. $ readelf -d ./result/bin/mono Dynamic section at offset 0x3784b0 contains 32 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] 0x0000000000000001 (NEEDED) Shared library: [libm.so.6] 0x0000000000000001 (NEEDED) Shared library: [librt.so.1] 0x0000000000000001 (NEEDED) Shared library: [libdl.so.2] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x000000000000000f (RPATH) Library rpath: [/nix/store/ygqw3h96jg0h77r2kb6ac98caw1mchh4-gcc-4.8.3/lib/../lib64:/nix/store/ikc9iziqc2rldacnbb2cdh7bdc1b2c3n-glibc- 2.19/lib] 0x000000000000001d (RUNPATH) Library runpath: [/nix/store/ygqw3h96jg0h77r2kb6ac98caw1mchh4-gcc-4.8.3/lib/../lib64:/nix/store/ikc9iziqc2rldacnbb2cdh7bdc1b2c3n-glibc- 2.19/lib] ...
  • 38. $ python --version Python 2.7.17 $ which python /usr/bin/python $ nix-shell -p python3 $ python --version Python 3.8.3 $ which python /nix/store/f87w21b91cws0wbsvyfn5vnlyv491czi-python3-3.8.3/bin/python
  • 40.
  • 41. • • • FROM nixos/nix RUN nix-channel --add https://nixos.org/channels/nixpkgs- unstable nixpkgs RUN nix-channel --update RUN nix-env -f '<nixpkgs>' -iA nginx RUN mkdir -p /var/log/nginx /var/cache/nginx /var/www ADD nginx.conf /etc ADD index.html /var/www CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx.conf"] EXPOSE 80/tcp
  • 43. with import <nixpkgs> {}; dockerTools.buildImage { name = "nginxexp"; tag = "test"; contents = nginx; runAsRoot = '' ${dockerTools.shadowSetup} groupadd -r nogroup useradd -r nobody -g nogroup -d /dev/null mkdir -p /var/log/nginx /var/cache/nginx /var/www cp ${./index.html} /var/www/index.html ''; config = { Cmd = [ "${nginx}/bin/nginx" "-g" "daemon off;" "-c" ./nginx.conf ]; Expose = { "80/tcp" = {}; }; }; }
  • 44. • • • $ nix-build /nix/store/qx9cpvdxj78d98rwfk6a5z2qsmqvgzvk-docker-image-nginxexp.tar.gz $ docker load -i result d8847b6d0466: Loading layer [==================================================>] 62.19MB/62.19MB Loaded image: nginxexp:test $ docker run -it -p 8080:80 nginxexp:test
  • 45. $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE mynginx latest 029491c6130e 14 hours ago 196MB nginxexp test cde8298f025f 50 years ago 61MB
  • 47. with import <nixpkgs> {}; dockerTools.buildLayeredImage { name = "nginxexp"; tag = "test"; contents = nginx; maxLayers = 100; extraCommands = '' mkdir -p var/log/nginx var/cache/nginx var/www cp ${./index.html} var/www/index.html ‘’; config = { Cmd = [ "${nginx}/bin/nginx" "-g" "daemon off;" "-c" ./nginx-root.conf ]; Expose = { "80/tcp" = {}; }; }; }
  • 48. $ docker history nginxexp:test IMAGE CREATED CREATED BY SIZE COMMENT b91799a04b99 50 years ago 1.47kB store paths: ['/nix/store/snxpdsksd4wxcn3niiyck0fry3wzri96-nginxexp-customisation-layer'] <missing> 50 years ago 200B store paths: ['/nix/store/6npz42nl2hhsrs98bq45aqkqsndpwvp1-nginx-root.conf'] <missing> 50 years ago 1.79MB store paths: ['/nix/store/qsq6ni4lxd8i4g9g4dvh3y7v1f43fqsp-nginx-1.18.0'] <missing> 50 years ago 492kB store paths: ['/nix/store/kdrdxhswaqm4dgdqs1vs2l4b4md7djma-pcre-8.44'] <missing> 50 years ago 4.17MB store paths: ['/nix/store/6glpgx3pypxzb09wxdqyagv33rrj03qp-openssl-1.1.1g'] ... <missing> 50 years ago 123kB store paths: ['/nix/store/5x6l9xm5dp6v113dpfv673qvhwjyb7p5-zlib-1.2.11'] <missing> 50 years ago 30.9MB store paths: ['/nix/store/bqbg6hb2jsl3kvf6jgmgfdqy06fpjrrn-glibc-2.30'] <missing> 50 years ago 209kB store paths: ['/nix/store/fhg84pzckx2igmcsvg92x1wpvl1dmybf-libidn2-2.3.0'] <missing> 50 years ago 1.63MB store paths: ['/nix/store/y8n2b9nwjrgfx3kvi3vywvfib2cw5xa6-libunistring-0.9.10']