Nix Piston: dev and prod containers
- Change appEnv to isDev - Determine the image name in api/default.nix - Use production image in ./piston test
This commit is contained in:
parent
c2bc1ebf94
commit
4578a9d15b
|
@ -1,4 +1,4 @@
|
|||
{pkgs, nosocket, appEnv, ...}:
|
||||
{pkgs, nosocket, isDev, ...}:
|
||||
with pkgs; rec {
|
||||
package = mkYarnPackage {
|
||||
name = "piston";
|
||||
|
@ -67,12 +67,12 @@ with pkgs; rec {
|
|||
'';
|
||||
|
||||
container = pkgs.dockerTools.buildLayeredImageWithNixDb {
|
||||
name = "piston";
|
||||
name = if isDev then "piston" else "ghcr.io/engineer-man/piston";
|
||||
tag = "base-latest";
|
||||
|
||||
contents = if appEnv == "dev" then basePackages ++ devPackages else basePackages;
|
||||
contents = if isDev then basePackages ++ devPackages else basePackages;
|
||||
|
||||
extraCommands = if appEnv == "dev" then baseCommands + devCommands else baseCommands;
|
||||
extraCommands = if isDev then baseCommands + devCommands else baseCommands;
|
||||
|
||||
config = {
|
||||
Cmd = ["${package}/bin/pistond"];
|
||||
|
|
|
@ -74,12 +74,12 @@
|
|||
containers = {
|
||||
dev = (import ./api {
|
||||
inherit pkgs nosocket;
|
||||
appEnv = "dev";
|
||||
isDev = true;
|
||||
}).container;
|
||||
|
||||
prod = (import ./api {
|
||||
inherit pkgs nosocket;
|
||||
appEnv = "prod";
|
||||
isDev = false;
|
||||
}).container;
|
||||
};
|
||||
};
|
||||
|
|
11
piston
11
piston
|
@ -17,7 +17,6 @@ build_base() {
|
|||
CONTAINER_PATH="$(nix build ".#$container_flake_key" --no-link --json | jq '.[0].outputs.out' -r)"
|
||||
echo "The image archive was created at: $CONTAINER_PATH"
|
||||
docker load -i $CONTAINER_PATH || exit 1
|
||||
docker tag "$IMAGE_NAME_DEV:$IMAGE_TAG" "$IMAGE_NAME:$IMAGE_TAG" || exit 1
|
||||
}
|
||||
|
||||
case "$SUBCOMMAND" in
|
||||
|
@ -41,16 +40,15 @@ case "$SUBCOMMAND" in
|
|||
|
||||
build)
|
||||
build_base
|
||||
runtime_set=all
|
||||
if [[ ! -z "$1" ]]; then
|
||||
runtime_set=$1
|
||||
fi
|
||||
# $1 contains a variant to build
|
||||
runtime_set=$1
|
||||
docker build \
|
||||
--build-arg RUNTIMESET=$runtime_set \
|
||||
-f "$SCRIPT_DIR"/Dockerfile.withset \
|
||||
-t "$IMAGE_NAME_DEV:$runtime_set-latest" \
|
||||
.
|
||||
fi
|
||||
;;
|
||||
|
||||
# dev commands
|
||||
|
@ -107,11 +105,11 @@ case "$SUBCOMMAND" in
|
|||
-e PISTON_FLAKE_PATH=/piston/src \
|
||||
-v "$SCRIPT_DIR":/piston/src \
|
||||
--name piston_test_runner \
|
||||
"$IMAGE_NAME_DEV:$IMAGE_TAG" \
|
||||
"$IMAGE_NAME:$IMAGE_TAG" \
|
||||
piston-test $1
|
||||
;;
|
||||
|
||||
test-with-cache)
|
||||
test-dev)
|
||||
docker run \
|
||||
--rm \
|
||||
-it \
|
||||
|
@ -147,6 +145,7 @@ case "$SUBCOMMAND" in
|
|||
echo " including the runtime set within it"
|
||||
echo " scaffold <language> [runtime] Initializes a new runtime"
|
||||
echo " test <runtime> Runs unit tests on the given runtime"
|
||||
echo " test-dev <runtime> Same as test, but using the development container and volume"
|
||||
echo " Optionally set runtime to --all to test all"
|
||||
echo " NOTE: This is only for the runtimes contained"
|
||||
echo " within this repo"
|
||||
|
|
Loading…
Reference in New Issue