Compare commits

...

2 commits
dev ... npm-nix

Author SHA1 Message Date
Yarmo Mackenbach
bda71db95d
feat: improve CI config 2024-06-14 10:03:33 +02:00
Yarmo Mackenbach
1e1a02fb99
feat: use npm and nix flake 2024-06-14 10:03:33 +02:00
13 changed files with 9858 additions and 5660 deletions

View file

@ -10,7 +10,7 @@ dist/
logs/ logs/
package.json package.json
yarn.lock package-lock.json
robots.txt robots.txt
\.licenseignore \.licenseignore
\.woodpecker.yml \.woodpecker.yml

View file

@ -1,57 +0,0 @@
steps:
test:
image: node
commands:
- yarn --pure-lockfile
- yarn run test
build-latest-container:
when:
branch: main
event: tag
image: plugins/docker
settings:
registry: https://codeberg.org/v2
username:
from_secret: codeberg_username
password:
from_secret: codeberg_password
repo: codeberg.org/keyoxide/keyoxide-web
tags: latest
build_args_from_env:
- CI_COMMIT_SHA
- CI_COMMIT_BRANCH
build-tag-container:
when:
branch: main
event: tag
image: plugins/docker
settings:
registry: https://codeberg.org/v2
username:
from_secret: codeberg_username
password:
from_secret: codeberg_password
repo: codeberg.org/keyoxide/keyoxide-web
auto_tag: true
build_args_from_env:
- CI_COMMIT_SHA
- CI_COMMIT_BRANCH
build-dev-container:
when:
branch: dev
event: push
image: plugins/docker
settings:
registry: https://codeberg.org/v2
username:
from_secret: codeberg_username
password:
from_secret: codeberg_password
repo: codeberg.org/keyoxide/keyoxide-web
tags: dev
build_args_from_env:
- CI_COMMIT_SHA
- CI_COMMIT_BRANCH

View file

@ -0,0 +1,20 @@
when:
branch: dev
event: push
steps:
build-latest-container:
image: woodpeckerci/plugin-docker-buildx
settings:
registry: https://codeberg.org/v2
username:
from_secret: codeberg_username
password:
from_secret: codeberg_password
repo: codeberg.org/keyoxide/keyoxide-web
tag: dev
build_args_from_env:
- CI_COMMIT_SHA
- CI_COMMIT_BRANCH
depends_on:
- test

20
.woodpecker/.release.yml Normal file
View file

@ -0,0 +1,20 @@
when:
branch: main
event: tag
steps:
build-latest-container:
image: woodpeckerci/plugin-docker-buildx
settings:
registry: https://codeberg.org/v2
username:
from_secret: codeberg_username
password:
from_secret: codeberg_password
repo: codeberg.org/keyoxide/keyoxide-web
auto_tag: true
build_args_from_env:
- CI_COMMIT_SHA
- CI_COMMIT_BRANCH
depends_on:
- test

8
.woodpecker/.test.yml Normal file
View file

@ -0,0 +1,8 @@
when:
event: [push, pull_request, tag, release, manual]
steps:
test:
image: node:20
commands:
- npm ci
- npm test

View file

@ -3,9 +3,9 @@ FROM node:20-alpine as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN yarn --pure-lockfile RUN npm ci
RUN yarn run build:server RUN npm run build:server
RUN yarn run build:static RUN npm run build:static
### ###

View file

@ -15,13 +15,13 @@ Self-hosting Keyoxide is an important aspect of the project. Users need to trust
### Docker ### Docker
The Docker container allows you to easily self-host the [Keyoxide](https://keyoxide.org) project. To get started, simply run: The Docker container allows you to easily self-host the [Keyoxide](https://keyoxide.org) project. To get started, run:
```sh ```sh
docker run -d -p 3000:3000 codeberg.org/keyoxide/keyoxide-web:latest docker run -d -p 3000:3000 codeberg.org/keyoxide/keyoxide-web:latest
``` ```
Keyoxide will now be available by visiting http://localhost:3000. Keyoxide will now be available at [http://localhost:3000](localhost:3000).
More information available in the [documentation](https://docs.keyoxide.org/guides/self-hosting/). More information available in the [documentation](https://docs.keyoxide.org/guides/self-hosting/).
@ -34,9 +34,29 @@ Install `node` in one of the following ways:
- using [nvm](https://github.com/nvm-sh/nvm) - using [nvm](https://github.com/nvm-sh/nvm)
- directly from their [website](https://nodejs.org/) - directly from their [website](https://nodejs.org/)
Install dependencies with `npm install` or `yarn`. Install the dependencies and run the server:
Run the server with `npm dev` or `yarn dev`. The Keyoxide web client will now be available at [https://localhost:3000](https://localhost:3000). ```sh
npm install
npm run dev
```
The web client will now be available at [http://localhost:3000](localhost:3000).
### Using nix
Enter a development shell:
```sh
nix develop
npm run dev
```
Alternatively, start a local server directly:
```sh
nix develop --command bash -c "npm run dev"
```
## Contributing ## Contributing

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1717144377,
"narHash": "sha256-F/TKWETwB5RaR8owkPPi+SPJh83AQsm6KrQAlJ8v/uA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "805a384895c696f802a9bf5bf4720f37385df547",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

28
flake.nix Normal file
View file

@ -0,0 +1,28 @@
{
description = "keyoxide-web";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
name = "keyoxide-web";
pkgs = import nixpkgs { inherit system; };
in
{
# nix develop
devShell = with pkgs; mkShell {
buildInputs = [
nodejs_20
];
shellHook = ''
echo "node: `${nodejs_20}/bin/node --version`"
echo "npm: `${nodejs_20}/bin/npm --version`"
'';
};
});
}

9688
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -48,14 +48,15 @@
}, },
"scripts": { "scripts": {
"start": "node ./", "start": "node ./",
"dev": "LOG_LEVEL=debug yarn run watch & yarn run build:static:dev", "dev": "LOG_LEVEL=debug npm run watch & npm run build:static:dev",
"test": "yarn run lint && mocha", "pretest": "npm run lint",
"test": "mocha",
"watch": "nodemon --config nodemon.json ./", "watch": "nodemon --config nodemon.json ./",
"build": "yarn run build:server && yarn run build:static", "build": "npm run build:server && npm run build:static",
"build:server": "ncc build ./src/index.js -o dist", "build:server": "ncc build ./src/index.js -o dist",
"build:static": "webpack --config webpack.config.js --env static=true --env mode=production", "build:static": "webpack --config webpack.config.js --env static=true --env mode=production",
"build:static:dev": "webpack --config webpack.config.js --env static=true --env mode=development", "build:static:dev": "webpack --config webpack.config.js --env static=true --env mode=development",
"lint": "yarn run standard:check && yarn run biome:check", "lint": "npm run standard:check && npm run biome:check",
"biome:check": "biome check ./src && biome lint ./src", "biome:check": "biome check ./src && biome lint ./src",
"biome:fix": "biome check --apply ./src && biome lint --apply ./src", "biome:fix": "biome check --apply ./src && biome lint --apply ./src",
"standard:check": "standard ./src", "standard:check": "standard ./src",

View file

@ -1,16 +0,0 @@
{ pkgs ? import <nixpkgs> {}}:
let
unstable = import (fetchTarball "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz") {};
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs
yarn
xvfb_run
unstable.cypress
];
CYPRESS_INSTALL_BINARY=0; #skip installing the Cypress binary from yarn
CYPRESS_RUN_BINARY="${unstable.cypress}/bin/Cypress";
}

5575
yarn.lock

File diff suppressed because it is too large Load diff