feat(18): not really working docker images
This commit is contained in:
parent
8ff2ec3766
commit
0af0129054
|
@ -1,5 +1,5 @@
|
||||||
rec {
|
rec {
|
||||||
description = "templ-practice";
|
description = "expenses chart exercise";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs";
|
nixpkgs.url = "github:nixos/nixpkgs";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
@ -11,7 +11,55 @@ rec {
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
templPkg = templ.packages.${system}.templ;
|
templPkg = templ.packages.${system}.templ;
|
||||||
in {
|
pname = "expenses-chart";
|
||||||
|
version = "0.0.1";
|
||||||
|
in rec {
|
||||||
|
thePackage = pkgs.buildGoModule {
|
||||||
|
inherit pname version;
|
||||||
|
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||||
|
vendorHash = "sha256-sKuP3TsRD3MXBGtdSRnX62eXBQE1ASWFQu0kLlXSlFA=";
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
# Adding the Tailwind build step to preBuild
|
||||||
|
${pkgs.nodePackages.tailwindcss}/bin/tailwindcss -i ./input.css -o static/output.css
|
||||||
|
# Adding generation of go code from templ files
|
||||||
|
${templPkg}/bin/templ generate
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
packages = rec {
|
||||||
|
"${pname}" = thePackage;
|
||||||
|
"${pname}-image" = pkgs.dockerTools.buildLayeredImage {
|
||||||
|
name = pname;
|
||||||
|
tag = "latest";
|
||||||
|
created = "now";
|
||||||
|
config = {
|
||||||
|
Cmd = [ "${thePackage}/bin/templ-exercise" ];
|
||||||
|
ExposedPorts = { "3000/tcp" = { }; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
image-hello = pkgs.dockerTools.buildLayeredImage { # so, wow, this works
|
||||||
|
name = pname;
|
||||||
|
tag = "latest";
|
||||||
|
config.Cmd = [ "${pkgs.hello}/bin/hello" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
image = pkgs.dockerTools.buildImage {
|
||||||
|
name = pname;
|
||||||
|
tag = "latest";
|
||||||
|
created = "now";
|
||||||
|
copyToRoot = pkgs.buildEnv {
|
||||||
|
name = "image-root";
|
||||||
|
paths = [ thePackage pkgs.dockerTools.binSh pkgs.coreutils ];
|
||||||
|
pathsToLink = [ "/bin" "/dist" "/public" ];
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
Cmd = [ "/bin/templ-exercise" ];
|
||||||
|
ExposedPorts = { "8080/tcp" = { }; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.go
|
pkgs.go
|
||||||
|
@ -20,7 +68,7 @@ rec {
|
||||||
pkgs.gopls
|
pkgs.gopls
|
||||||
pkgs.gnumake
|
pkgs.gnumake
|
||||||
templPkg
|
templPkg
|
||||||
pkgs.tailwindcss
|
pkgs.nodePackages.tailwindcss
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export GOPATH=$PWD/.go
|
export GOPATH=$PWD/.go
|
||||||
|
|
|
@ -74,3 +74,34 @@ because then if parent would want to have child take up all space - negative pad
|
||||||
|
|
||||||
*** allright, @ to include sub templates
|
*** allright, @ to include sub templates
|
||||||
|
|
||||||
|
** well, last part? preparing the docker container for deployment on Render.com?
|
||||||
|
|
||||||
|
which port should be used?
|
||||||
|
also, this would be first time i'll add templ as a build step
|
||||||
|
|
||||||
|
** for some reason image doesn't work well
|
||||||
|
|
||||||
|
podman run -d -p 9090:8080 localhost/expenses-chart:latest /nix/store/l4r6glmzbvkhg97lp4dn7nm76w6hz41g-expenses-chart-0.0.1/bin/temp-exercise
|
||||||
|
|
||||||
|
this runs,
|
||||||
|
but podman run -it expenses-chart:latest
|
||||||
|
Error: crun: executable file `/nix/store/l4r6glmzbvkhg97lp4dn7nm76w6hz41g-expenses-chart-0.0.1/bin/templ-exercise` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
|
||||||
|
|
||||||
|
oh, well
|
||||||
|
|
||||||
|
** you know what - i give up
|
||||||
|
|
||||||
|
for some reason when i open url to app running in container,
|
||||||
|
and it's on the 8080 port of the host machine - the static files are served
|
||||||
|
|
||||||
|
if i use any other port of local machine, to forward into container,
|
||||||
|
the static files are not served
|
||||||
|
|
||||||
|
maybe this is bug in go? i don't know
|
||||||
|
StripPrefix doesn't seem to do anything
|
||||||
|
|
||||||
|
and for some reason in this specific exercise CMD doesn't work in the container
|
||||||
|
so let's just give up!
|
||||||
|
|
||||||
|
i could try to write a docker file and check with that, but yeah
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue