blob: a04131b15a8575c81988b1056fbdb4aaac993f04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
{ pkgs, self }:
let
revision = "${self.lastModifiedDate}-${self.shortRev or "dirty"}";
version = "unstable-${self.shortRev or "dirty"}";
mkDocker = server:
let
PORT = 3000;
in
pkgs.dockerTools.streamLayeredImage {
name = "registry.fly.io/alanpearce-eu";
tag = revision;
contents = [ server ];
config = {
Cmd = [ "website" ];
Env = [
"PRODUCTION=true"
"PORT=${builtins.toString PORT}"
"ROOT=public"
];
ExposedPorts = {
"${builtins.toString PORT}/tcp" = { };
};
};
};
in
rec {
default = server;
builder = pkgs.buildGoApplication {
pname = "website-builder";
inherit version;
src = with pkgs.lib.fileset; toSource {
root = ./..;
fileset = unions [
./../go.mod
./../go.sum
./../cmd
./../internal
];
};
modules = ./gomod2nix.toml;
subPackages = [ "cmd/build" ];
};
server = pkgs.buildGoApplication {
pname = "website";
inherit version;
CGO_ENABLED = 0;
src = with pkgs.lib.fileset; toSource {
root = ./..;
fileset = unions [
./../go.mod
./../go.sum
./../server.go
./../internal
./../config.toml
./../content
./../static
./../templates
];
};
buildInputs = [ builder ];
prePatch = ''
${builder}/bin/build
'';
modules = ./gomod2nix.toml;
ldflags = [ "-s" "-w" ];
};
docker = mkDocker server;
docker-aarch64-linux = mkDocker (self.packages.aarch64-linux.server);
docker-x86_64-linux = mkDocker (self.packages.x86_64-linux.server);
fly = docker-x86_64-linux;
}
|