graphql-engine/v3/nix/docker.nix
Daniel Harvey a47327a9bf Add cacert to docker image (#782)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Allow engine to connect to NDCs via HTTPS.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Add `cacert` to Docker image using Nix.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 52458920236f3868cc8daf18e140f8536d9bc674
2024-06-28 10:06:18 +00:00

33 lines
810 B
Nix

# This is a function that returns a derivation for a docker image.
{ dockerTools
, lib
, package
, image-name
, pkgs
, port
, architecture ? null
, tag ? null # defaults to the output hash
, extraConfig ? { } # see config options at: https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions
}:
let
seconds = 1000 * 1000 * 1000; # nanoseconds in 1 second
args = {
name = image-name;
created = "now";
contents = [ pkgs.cacert package ];
config = {
Entrypoint = [
"/bin/${package.pname}"
];
ExposedPorts = { "${port}/tcp" = { }; };
} // extraConfig;
}
// lib.optionalAttrs (tag != null) {
inherit tag;
} // lib.optionalAttrs (architecture != null) {
inherit architecture;
};
in
dockerTools.buildLayeredImage args