Commit 4c8281ed authored by Millian Poquet's avatar Millian Poquet
Browse files

env: build oarteam/batsim_ci with nix

parent f1b400b5
FROM nixos/nix:2.2.1
RUN nix-channel --remove nixpkgs \
&& nix-channel --add https://nixos.org/channels/nixos-19.03 nixpkgs \
&& nix-channel --update \
&& nix-env -f '<nixpkgs>' -iA \
bash \
coreutils \
curl \
findutils \
gitMinimal \
glibc \
gnugrep \
gnused \
gnutar \
gzip \
netcat-gnu \
openssh \
psmisc \
rsync \
which \
xz \
&& nix-env -if https://github.com/cachix/cachix/tarball/master \
--substituters https://cachix.cachix.org \
--trusted-public-keys \
cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM= \
&& cachix use batsim \
&& nix-collect-garbage -d \
&& ln -s $(realpath $(which bash)) /bin/bash
default:
@echo "Try make build, make build-nocache or make push."
build:
docker build -t oarteam/batsim_ci:latest \
-t oarteam/batsim_ci:$$(date --iso-8601) \
.
image: default.nix
nix-build default.nix -A batsim-ci-image -o image
build-nocache:
docker build -t oarteam/batsim_ci:latest \
-t oarteam/batsim_ci:$$(date --iso-8601) \
--no-cache \
.
build: image
docker load -i ./image && docker tag oarteam/batsim_ci:latest oarteam/batsim_ci:$$(date --iso-8601)
push:
docker push oarteam/batsim_ci
docker push oarteam/batsim_ci:$$(date --iso-8601) && docker push oarteam/batsim_ci:latest
This directory contains:
- the [definition](./Dockerfile) of the Docker container used for Batsim
continuous integration system
- a wrapper to easily update the container and push it on
[Docker Hub](https://hub.docker.com/r/oarteam/batsim_ci/)
Build
=====
This directory contains the definition of the main Docker container used by the CIs of the Batsim ecosystem.
To use docker cache, simply run ``make build``.
To disable docker cache: ``make build-nocache``.
Push to Docker Hub
==================
List of files.
- [default.nix](./default.nix) defines how to build the container.
- [Makefile](./Makefile) is a wrapper to build/push the container on
[Docker Hub](https://hub.docker.com/r/oarteam/batsim_ci/)
``` bash
make push
```
List of commands.
- Build: ``make build``
- Push on Docker Hub: ``make push``
{ pkgs ? import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/21.05.tar.gz";
sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
}) {}
}:
let
self = rec {
nix-image = pkgs.dockerTools.pullImage {
imageName = "nixpkgs/cachix";
imageDigest = "sha256:fe785cb65b7bcd332154183e4509ef9b6aeb9913d5b13fb6312df6ee9cc8a543";
sha256 = "10jb3l46zz5vvpfddc24ppp0cibgdgkxi33n459dr5b7h0fhk51v";
os = "linux";
arch = "amd64";
};
batsim-ci-image = pkgs.dockerTools.buildImage {
name = "oarteam/batsim_ci";
tag = "latest";
created = "now";
fromImage = nix-image;
contents = [
# - enable `nix` and `nix flakes` commands
# - enable pull from batsim/capack cachix binary caches
(pkgs.writeTextFile {
name = "nix.conf";
destination = "/etc/nix/nix.conf";
text = ''
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://batsim.cachix.org https://capack.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= batsim.cachix.org-1:IQ/4c8P/yzhxQwp6t58LatLcvHz0qMolEHJQz9w9pxc= capack.cachix.org-1:38D+QFk3JXvMYJuhSaZ+3Nm/Qh+bZJdCrdu4pkIh5BU=
'';
})
];
# required by gitlab-ci runner
config.Entrypoint = ["/bin/bash" "-c"];
};
};
in
self
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment