feat: docker image for results component

This commit is contained in:
efim
2023-10-04 10:39:33 +00:00
parent f48d958a2c
commit b0dd8cded1
4 changed files with 34 additions and 6 deletions

View File

@@ -1,7 +1,27 @@
{ config, lib, pkgs, ... }:
let pname = "countries-page";
in {
# todo, building app
# building docker image
{ lib, pkgs, ... }:
let
pname = "results-summary-component";
version = "0.0.1";
in rec {
package = pkgs.buildGoModule {
inherit pname version;
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
vendorHash = null; # set to "" when get dependencies in go.mod
};
image = pkgs.dockerTools.buildLayeredImage {
name = pname;
tag = "latest";
created = "now";
config = {
Cmd = [
"${package}/bin/results-summary-component-go"
"-p"
"8080"
"-h"
"0.0.0.0"
];
ExposedPorts = { "8080/tcp" = { }; };
};
};
# nixos module
}

View File

@@ -68,10 +68,12 @@ func main() {
})
var port int
var host string
flag.IntVar(&port, "p", 8080, "Specify port for server to start on")
flag.StringVar(&host, "h", "localhost", "Specify host for server to start on")
flag.Parse()
address := fmt.Sprintf("localhost:%d", port)
address := fmt.Sprintf("%s:%d", host, port)
log.Printf("starting server on %s", address)
log.Fatal(http.ListenAndServe(address, nil))
}

Binary file not shown.