working prototype for a container deployment
This commit is contained in:
parent
5813a9f14d
commit
9670c4683c
2
.envrc
2
.envrc
|
@ -2,6 +2,6 @@
|
|||
use flake
|
||||
|
||||
watch_file ./nix/checks.nix
|
||||
watch_file ./nix/dev-shell.nix
|
||||
watch_file ./nix/shell.nix
|
||||
|
||||
eval "$shellHook"
|
||||
|
|
41
.gitignore
vendored
41
.gitignore
vendored
|
@ -1,24 +1,19 @@
|
|||
# nix
|
||||
.direnv
|
||||
.pre-commit-config.yaml
|
||||
|
||||
# build output
|
||||
dist/
|
||||
.output/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
# default
|
||||
.DS_Store
|
||||
*.log*
|
||||
|
||||
# nix
|
||||
.pre-commit-config.yaml
|
||||
.direnv/
|
||||
result
|
||||
|
||||
# node
|
||||
.output/
|
||||
# dist/
|
||||
node_modules/
|
||||
out/
|
||||
dist/
|
||||
|
||||
# environment
|
||||
.env
|
||||
.env.production
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -8,4 +8,4 @@
|
|||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
18
.vscode/tasks.json
vendored
Normal file
18
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "watch tests",
|
||||
"type": "shell",
|
||||
"command": "watch --color 'nix-build test --no-out-link | xargs cat'",
|
||||
"presentation": {
|
||||
"echo": false,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "dedicated",
|
||||
"showReuseMessage": false
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
42
README.md
42
README.md
|
@ -1,16 +1,7 @@
|
|||
# Welcome to [Astro](https://astro.build)
|
||||
|
||||
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
|
||||
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/s/github/withastro/astro/tree/latest/examples/basics)
|
||||
|
||||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||
|
||||
![basics](https://user-images.githubusercontent.com/4677417/186188965-73453154-fdec-4d6b-9c34-cb35c248ae5b.png)
|
||||
|
||||
## 🚀 Project Structure
|
||||
|
||||
Inside of your Astro project, you'll see the following folders and files:
|
||||
|
||||
```txt
|
||||
/
|
||||
├── public/
|
||||
|
@ -25,15 +16,9 @@ Inside of your Astro project, you'll see the following folders and files:
|
|||
└── package.json
|
||||
```
|
||||
|
||||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
|
||||
|
||||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
|
||||
|
||||
Any static assets, like images, can be placed in the `public/` directory.
|
||||
|
||||
## 🧞 Commands
|
||||
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
### Astro
|
||||
|
||||
| Command | Action |
|
||||
| :--------------------- | :------------------------------------------------- |
|
||||
|
@ -44,6 +29,27 @@ All commands are run from the root of the project, from a terminal:
|
|||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro preview` |
|
||||
| `npm run astro --help` | Get help using the Astro CLI |
|
||||
|
||||
## 👀 Want to learn more?
|
||||
### Nix
|
||||
|
||||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
|
||||
```sh
|
||||
nix build .\#astro-cms -o ./build/astro-cms.tgz
|
||||
docker load --input=./build/astro-cms.tgz
|
||||
docker run --rm -it -p 8888:8888 -v $HOME:/mnt cyanovision
|
||||
```
|
||||
|
||||
- https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/examples.nix
|
||||
|
||||
docker load --input ./result
|
||||
docker run -it -p 127.0.0.1:8080:80/tcp code.curious.bio/curious.bio/planktoscope # https://tulpa.dev/cadey/astro-http/src/branch/main/flake.nix
|
||||
|
||||
````
|
||||
|
||||
```sh
|
||||
nix build .\#astro-runtime
|
||||
nix build .\#web-service
|
||||
nix build .\#portable-service
|
||||
````
|
||||
|
||||
## Documentation
|
||||
|
||||
- https://ryantm.github.io/nixpkgs/builders/images/dockertools/
|
||||
|
|
33
flake.lock
33
flake.lock
|
@ -100,6 +100,38 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1653917367,
|
||||
"narHash": "sha256-04MsJC0g9kE01nBuXThMppZK+yvCZECQnUaZKSU+HJo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "437c8e6554911095f0557d524e9d2ffe1c26e33a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"npm-buildpackage": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1670813451,
|
||||
"narHash": "sha256-v0IvQ35CMKtPreGlxWb1FvFUraJNZd144+MbiDwGoAA=",
|
||||
"owner": "serokell",
|
||||
"repo": "nix-npm-buildpackage",
|
||||
"rev": "ec0365cd14a3359a23b80a9e2531a09afc3488fc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "serokell",
|
||||
"repo": "nix-npm-buildpackage",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
|
@ -131,6 +163,7 @@
|
|||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"npm-buildpackage": "npm-buildpackage",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
}
|
||||
}
|
||||
|
|
105
flake.nix
105
flake.nix
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
description = "srx.nix.astro";
|
||||
description = "srx.astro.nix";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
@ -12,20 +12,117 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
};
|
||||
npm-buildpackage.url = "github:serokell/nix-npm-buildpackage";
|
||||
};
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: {
|
||||
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux"] (
|
||||
system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
version = builtins.substring 0 8 self.lastModifiedDate;
|
||||
astro-modules = pname: version: src:
|
||||
pkgs.mkYarnModules {
|
||||
pname = "${pname}-modules";
|
||||
inherit version;
|
||||
packageJSON = "${src}/package.json";
|
||||
yarnLock = ./yarn.lock;
|
||||
yarnNix = ./nix/yarn.nix;
|
||||
# postBuild = ''
|
||||
# cp -r $out/node_modules/ $out/node_modules/
|
||||
# '';
|
||||
};
|
||||
in {
|
||||
checks = import ./nix/checks.nix inputs system;
|
||||
devShells.default = import ./nix/shell.nix inputs system;
|
||||
|
||||
packages = {
|
||||
astro-package-nix = pkgs.stdenv.mkDerivation rec {
|
||||
pname = "srx-portfolio";
|
||||
inherit version;
|
||||
src = ./.;
|
||||
nativeBuildInputs = [
|
||||
pkgs.nodejs
|
||||
];
|
||||
buildPhase = ''
|
||||
ln -sf ${astro-modules pname version src}/node_modules node_modules
|
||||
export NODE_OPTIONS='--unhandled-rejections=warn'
|
||||
npm --update-notifier=false run build
|
||||
'';
|
||||
installPhase = ''
|
||||
mv dist $out
|
||||
'';
|
||||
};
|
||||
|
||||
nginx-container-docker = pkgs.dockerTools.buildImage {
|
||||
name = "nginx";
|
||||
tag = version;
|
||||
copyToRoot = pkgs.buildEnv {
|
||||
name = "base-config";
|
||||
pathsToLink = ["/bin"];
|
||||
paths = [
|
||||
pkgs.dockerTools.fakeNss
|
||||
pkgs.nginx
|
||||
];
|
||||
};
|
||||
runAsRoot = ''
|
||||
#!${pkgs.runtimeShell}
|
||||
${pkgs.dockerTools.shadowSetup}
|
||||
groupadd --system nginx
|
||||
useradd --system --gid nginx nginx
|
||||
'';
|
||||
extraCommands = ''
|
||||
mkdir -p tmp/nginx_client_body
|
||||
mkdir -p var/log/nginx
|
||||
mkdir -p var/cache/nginx
|
||||
'';
|
||||
};
|
||||
|
||||
astro-container-docker = let
|
||||
nginxPort = "8080";
|
||||
nginxConf = pkgs.writeText "nginx.conf" ''
|
||||
user nginx nginx;
|
||||
daemon off;
|
||||
error_log /dev/stdout info;
|
||||
pid /dev/null;
|
||||
events {}
|
||||
http {
|
||||
access_log /dev/stdout;
|
||||
server {
|
||||
listen ${nginxPort};
|
||||
index index.html;
|
||||
location / {
|
||||
root ${self.packages.${system}.default};
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
in
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "astro";
|
||||
tag = version;
|
||||
fromImage = self.packages.${system}.nginx-container-docker;
|
||||
copyToRoot = pkgs.buildEnv {
|
||||
name = "image-www";
|
||||
paths = [self.packages.${system}.default];
|
||||
};
|
||||
config = {
|
||||
Cmd = ["nginx" "-c" nginxConf];
|
||||
ExposedPorts = {
|
||||
"${nginxPort}/tcp" = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = self.packages.${system}.astro-package-nix;
|
||||
};
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
config.allowAliases = true;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
{self, ...}: system:
|
||||
with self.pkgs.${system};
|
||||
mkShell {
|
||||
name = "srx.nix.astro";
|
||||
name = "srx.astro.nix";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
# nix
|
||||
alejandra
|
||||
editorconfig-checker
|
||||
git
|
||||
nix-linter
|
||||
nodejs
|
||||
pre-commit
|
||||
rnix-lsp
|
||||
vscodium-fhs
|
||||
|
||||
# node
|
||||
nodejs
|
||||
yarn
|
||||
yarn2nix
|
||||
prefetch-npm-deps
|
||||
|
||||
# dev
|
||||
git
|
||||
editorconfig-checker
|
||||
pre-commit
|
||||
skopeo
|
||||
vscodium-fhs
|
||||
];
|
||||
postInstall = '''';
|
||||
shellHook = ''
|
||||
${self.checks.${system}.pre-commit-check.shellHook}
|
||||
export PATH="$PWD/node_modules/.bin/:$PATH"
|
||||
'';
|
||||
}
|
||||
|
|
3763
nix/yarn.nix
Normal file
3763
nix/yarn.nix
Normal file
File diff suppressed because it is too large
Load diff
14
package.json
14
package.json
|
@ -1,8 +1,14 @@
|
|||
{
|
||||
"name": "@srx/portfolio",
|
||||
"name": "srx-portfolio",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"author": "Sebastian Wendel",
|
||||
"homepage": "https://srx.dev",
|
||||
"repository": {
|
||||
"url": "https://github.com/sourceindex/srx.astro.nix.git",
|
||||
"type": "git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
|
@ -12,5 +18,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"astro": "^1.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.8.1",
|
||||
"prettier-plugin-astro": "^0.7.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/strict"
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"compilerOptions": {
|
||||
"importsNotUsedAsValues": "error",
|
||||
}
|
||||
}
|
24
yarn.lock
24
yarn.lock
|
@ -120,9 +120,9 @@
|
|||
"@babel/highlight" "^7.18.6"
|
||||
|
||||
"@babel/compat-data@^7.20.5":
|
||||
version "7.20.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.5.tgz#86f172690b093373a933223b4745deeb6049e733"
|
||||
integrity sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g==
|
||||
version "7.20.10"
|
||||
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.10.tgz#9d92fa81b87542fff50e848ed585b4212c1d34ec"
|
||||
integrity sha512-sEnuDPpOJR/fcafHMjpcpGN5M2jbUGUHwmuWKM/YdPzeEDJg8bgmbcWQFUfE32MQjti1koACvoPVsDe8Uq+idg==
|
||||
|
||||
"@babel/core@^7.18.2":
|
||||
version "7.20.7"
|
||||
|
@ -200,9 +200,9 @@
|
|||
"@babel/types" "^7.18.6"
|
||||
|
||||
"@babel/helper-module-transforms@^7.20.7":
|
||||
version "7.20.7"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.7.tgz#7a6c9a1155bef55e914af574153069c9d9470c43"
|
||||
integrity sha512-FNdu7r67fqMUSVuQpFQGE6BPdhJIhitoxhGzDbAXNcA07uoVG37fOiMk3OSV8rEICuyG6t8LGkd9EE64qIEoIA==
|
||||
version "7.20.11"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.11.tgz#df4c7af713c557938c50ea3ad0117a7944b2f1b0"
|
||||
integrity sha512-uRy78kN4psmji1s2QtbtcCSaj/LILFDp0f/ymhpQH5QY3nljUZCaNWz9X1dEj/8MBdBEFECs7yRhKn8i7NjZgg==
|
||||
dependencies:
|
||||
"@babel/helper-environment-visitor" "^7.18.9"
|
||||
"@babel/helper-module-imports" "^7.18.6"
|
||||
|
@ -210,7 +210,7 @@
|
|||
"@babel/helper-split-export-declaration" "^7.18.6"
|
||||
"@babel/helper-validator-identifier" "^7.19.1"
|
||||
"@babel/template" "^7.20.7"
|
||||
"@babel/traverse" "^7.20.7"
|
||||
"@babel/traverse" "^7.20.10"
|
||||
"@babel/types" "^7.20.7"
|
||||
|
||||
"@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.20.2":
|
||||
|
@ -297,10 +297,10 @@
|
|||
"@babel/parser" "^7.20.7"
|
||||
"@babel/types" "^7.20.7"
|
||||
|
||||
"@babel/traverse@^7.18.2", "@babel/traverse@^7.20.7":
|
||||
version "7.20.8"
|
||||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.8.tgz#e3a23eb04af24f8bbe8a8ba3eef6155b77df0b08"
|
||||
integrity sha512-/RNkaYDeCy4MjyV70+QkSHhxbvj2JO/5Ft2Pa880qJOG8tWrqcT/wXUuCCv43yogfqPzHL77Xu101KQPf4clnQ==
|
||||
"@babel/traverse@^7.18.2", "@babel/traverse@^7.20.10", "@babel/traverse@^7.20.7":
|
||||
version "7.20.10"
|
||||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.10.tgz#2bf98239597fcec12f842756f186a9dde6d09230"
|
||||
integrity sha512-oSf1juCgymrSez8NI4A2sr4+uB/mFd9MXplYGPEBnfAuWmmyeVcHa6xLPiaRBcXkcb/28bgxmQLTVwFKE1yfsg==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.18.6"
|
||||
"@babel/generator" "^7.20.7"
|
||||
|
@ -2553,7 +2553,7 @@ prettier-plugin-astro@^0.7.0:
|
|||
sass-formatter "^0.7.5"
|
||||
synckit "^0.8.4"
|
||||
|
||||
prettier@^2.7.1:
|
||||
prettier@^2.7.1, prettier@^2.8.1:
|
||||
version "2.8.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.1.tgz#4e1fd11c34e2421bc1da9aea9bd8127cd0a35efc"
|
||||
integrity sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==
|
||||
|
|
Loading…
Reference in a new issue