Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature: containerization #7

Closed
aleeusgr opened this issue Dec 24, 2023 · 3 comments
Closed

add feature: containerization #7

aleeusgr opened this issue Dec 24, 2023 · 3 comments

Comments

@aleeusgr
Copy link
Owner

aleeusgr commented Dec 24, 2023

We typically wrap our applications in a Docker image and deploy to some service that natively runs containers.

... can accept public traffic
... we have root access to via SSH

https://nixos.wiki/wiki/NixOS_Containers
https://nix.dev/tutorials/nixos/building-and-running-docker-images.html

@aleeusgr aleeusgr changed the title feature: docker feature: container Dec 24, 2023
@aleeusgr aleeusgr changed the title feature: container feat: container Dec 24, 2023
@aleeusgr
Copy link
Owner Author

aleeusgr commented Dec 24, 2023

nixosConfigurations.container = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules =
        [ ({ pkgs, ... }: {
            boot.isContainer = true;

            # Let 'nixos-version --json' know about the Git revision
            # of this flake.
            system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;

            # Network configuration.
            networking.useDHCP = false;
            networking.firewall.allowedTCPPorts = [ 80 ];

            # Enable a web server.
            services.httpd = {
              enable = true;
              adminAddr = "[email protected]";
            };
          })
        ];
    };
nixos-container create <name> --flake .
nixos-container start <name>
nixos-container run <name> -- uname -a
nixos-container show-ip <name>

@aleeusgr
Copy link
Owner Author

error: syntax error, unexpected '=', expecting ';'

       at /nix/store/2yfdc4izlb4820w3l8sdyzjaimkssvmj-source/flake.nix:9:33:

            8|   outputs = { self, nixpkgs, utils, naersk }:
            9|   nixosConfigurations.container = nixpkgs.lib.nixosSystem {
             |                                 ^
           10|       system = "x86_64-linux";

@aleeusgr aleeusgr linked a pull request Dec 25, 2023 that will close this issue
@aleeusgr aleeusgr changed the title feat: container add feature: containerization Dec 25, 2023
@aleeusgr
Copy link
Owner Author

fixed in #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant