fix
continuous-integration/drone/push Build is failing Details

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-01-01 20:52:07 -05:00
parent 6dd28cab1e
commit b1f6e6d823
5 changed files with 49 additions and 49 deletions

View File

@ -1,20 +1,26 @@
{ system ? builtins.currentSystem }: { sources ? import ./nix/sources.nix, pkgs ? import <nixpkgs> { } }:
let let
sources = import ./nix/sources.nix; srcNoTarget = dir:
pkgs = import <nixpkgs> { }; builtins.filterSource
printerfacts = import ./printerfacts.nix { inherit pkgs sources; }; (path: type: type != "directory" || builtins.baseNameOf path != "target")
dir;
name = "xena/printerfacts"; naersk = pkgs.callPackage sources.naersk { };
tag = "latest"; gruvbox-css = pkgs.callPackage sources.gruvbox-css { };
src = srcNoTarget ./.;
in pkgs.dockerTools.buildLayeredImage { pfacts = naersk.buildPackage {
inherit name tag; inherit src;
contents = [ printerfacts ]; remapPathPrefix = true;
config = {
Cmd = [ "${printerfacts}/bin/printerfacts" ];
Env = [ "RUST_LOG=info" ];
WorkingDir = "/";
}; };
in pkgs.stdenv.mkDerivation {
inherit (pfacts) name;
inherit src;
phases = "installPhase";
installPhase = ''
mkdir -p $out/static
cp -rf $src/templates $out/templates
cp -rf ${pfacts}/bin $out/bin
cp -rf ${gruvbox-css}/gruvbox.css $out/static/gruvbox.css
'';
} }

20
docker.nix Normal file
View File

@ -0,0 +1,20 @@
{ system ? builtins.currentSystem }:
let
sources = import ./nix/sources.nix;
pkgs = import <nixpkgs> { };
printerfacts = import ./default.nix { inherit pkgs sources; };
name = "xena/printerfacts";
tag = "latest";
in pkgs.dockerTools.buildLayeredImage {
inherit name tag;
contents = [ printerfacts ];
config = {
Cmd = [ "${printerfacts}/bin/printerfacts" ];
Env = [ "RUST_LOG=info" ];
WorkingDir = "/";
};
}

View File

@ -1,26 +0,0 @@
{ sources ? import ./nix/sources.nix, pkgs ? import <nixpkgs> { } }:
let
srcNoTarget = dir:
builtins.filterSource
(path: type: type != "directory" || builtins.baseNameOf path != "target")
dir;
naersk = pkgs.callPackage sources.naersk { };
gruvbox-css = pkgs.callPackage sources.gruvbox-css { };
src = srcNoTarget ./.;
pfacts = naersk.buildPackage {
inherit src;
remapPathPrefix = true;
};
in pkgs.stdenv.mkDerivation {
inherit (pfacts) name;
inherit src;
phases = "installPhase";
installPhase = ''
mkdir -p $out/static
cp -rf $src/templates $out/templates
cp -rf ${pfacts}/bin $out/bin
cp -rf ${gruvbox-css}/gruvbox.css $out/static/gruvbox.css
'';
}

View File

@ -1,6 +1,5 @@
let let
pkgs = import <nixpkgs> { }; pkgs = import <nixpkgs> { };
dhall = import <dhall> { };
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
rustc rustc
@ -8,9 +7,6 @@ in pkgs.mkShell {
cargo-watch cargo-watch
rls rls
rustfmt rustfmt
dhall.linux-dhall
dhall.linux-dhall-yaml
]; ];
RUST_LOG = "info"; RUST_LOG = "info";

View File

@ -57,8 +57,12 @@ async fn main() -> anyhow::Result<()> {
.and_then(index); .and_then(index);
let not_found_handler = warp::any().and_then(not_found); let not_found_handler = warp::any().and_then(not_found);
let port = std::env::var("PORT")
.unwrap_or("5000".into())
.parse::<u16>()
.expect("PORT to be a string-encoded u16");
log::info!("listening on port 5000"); log::info!("listening on port {}", port);
warp::serve( warp::serve(
fact_handler fact_handler
.or(index_handler) .or(index_handler)
@ -66,7 +70,7 @@ async fn main() -> anyhow::Result<()> {
.or(not_found_handler) .or(not_found_handler)
.with(warp::log(APPLICATION_NAME)), .with(warp::log(APPLICATION_NAME)),
) )
.run(([0, 0, 0, 0], 5000)) .run(([0, 0, 0, 0], port))
.await; .await;
Ok(()) Ok(())
} }