Skip to content

Commit

Permalink
feat: upgrade to nodejs18 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop authored Sep 14, 2023
1 parent 942c8bd commit 52909f3
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 97 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:16-alpine
FROM node:18-alpine


# * Same version as in Watchtower
ARG EXPRESS_VERSION=4.18.1
ARG EXPRESS_VERSION=4.18.2
ENV EXPRESS_VERSION $EXPRESS_VERSION

# * path to the server files
Expand Down
77 changes: 77 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
description = "Nhost Functions";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-filter.url = "github:numtide/nix-filter";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, nix-filter }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
(final: prev: {
nodejs = prev.nodejs-18_x;
})
];

pkgs = import nixpkgs {
inherit overlays system;
};

nix-src = nix-filter.lib.filter {
root = ./.;
include = [
(nix-filter.lib.matchExt "nix")
];
};

node_modules = pkgs.stdenv.mkDerivation {
inherit version;

pname = "node_modules";

nativeBuildInputs = with pkgs; [
nodePackages.pnpm
];

src = nix-filter.lib.filter {
root = ./.;
include = [
./package.json
./pnpm-lock.yaml
];
};


buildPhase = ''
pnpm install
'';

installPhase = ''
mkdir -p $out
cp -r node_modules $out
'';
};


name = "functions";
version = "0.0.0-dev";

buildInputs = with pkgs;[
nodejs
];
nativeBuildInputs = with pkgs; [
nodePackages.pnpm
];
in
{
checks = {
nixpkgs-fmt = pkgs.runCommand "check-nixpkgs-fmt"
{
nativeBuildInputs = with pkgs;
[
nixpkgs-fmt
];
}
''
mkdir $out
nixpkgs-fmt --check ${nix-src}
'';

};

devShells = flake-utils.lib.flattenTree rec {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nixpkgs-fmt
gnumake
] ++ buildInputs ++ nativeBuildInputs;

shellHook = ''
export PATH=${node_modules}/node_modules/.bin:$PATH
rm -rf node_modules
ln -sf ${node_modules}/node_modules/ node_modules
'';
};
};
}
);
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
"homepage": "https://github.com/nhost/functions#readme",
"devDependencies": {
"@antfu/ni": "^0.17.2",
"@swc-node/register": "^1.6.5",
"@swc-node/register": "^1.6.7",
"@swc/core": "^1.3.84",
"@types/express": "^4.17.17",
"@types/glob": "^7.2.0",
"@types/morgan": "^1.9.4",
"@types/node": "^18.16.14",
"@types/morgan": "^1.9.5",
"@types/node": "^18.17.15",
"express": "4.18.1",
"glob": "^8.1.0",
"morgan": "^1.10.0",
"nodemon": "^2.0.22",
"pnpm": "^7.32.4",
"pnpm": "^7.33.6",
"typescript": "^4.9.5"
}
}
Loading

0 comments on commit 52909f3

Please sign in to comment.