chore: migrate to Nix flakes, remove Docker and legacy configs

Remove all Docker files, Vercel config, Verdaccio, and old CI workflow.
Standardize on nodejs_22 across devShell and nix build helpers.
Update CI to build all packages and push to Cachix on merge to develop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
maulanasdqn
2026-03-30 23:05:37 +07:00
co-authored by Claude Opus 4.6
parent 3de1748f12
commit bbb1bae909
26 changed files with 90 additions and 496 deletions
-55
View File
@@ -1,55 +0,0 @@
# Dependencies
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Build outputs
dist
.next
out
build
coverage
# IDE
.vscode
.idea
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db
# Git
.git
.gitignore
# Environment
.env
.env.local
.env.*.local
# Testing
coverage
.nyc_output
# Logs
logs
*.log
# Nx
.nx
# Docker
Dockerfile
docker-compose*.yml
.dockerignore
# Misc
*.md
!README.md
.editorconfig
.prettierrc
.eslintrc
+10 -7
View File
@@ -29,12 +29,15 @@ jobs:
nix build .#dimentorin -o result-dimentorin
nix build .#hackathon -o result-hackathon
nix build .#infra -o result-infra
nix build .#qrcampaign -o result-qrcampaign
- name: Show build outputs
- name: Push to Cachix
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
run: |
echo "Landing: $(readlink result-landing)"
echo "Backoffice: $(readlink result-backoffice)"
echo "Gacha: $(readlink result-gacha)"
echo "Dimentorin: $(readlink result-dimentorin)"
echo "Hackathon: $(readlink result-hackathon)"
echo "Infra: $(readlink result-infra)"
cachix push msdqn result-landing
cachix push msdqn result-backoffice
cachix push msdqn result-gacha
cachix push msdqn result-dimentorin
cachix push msdqn result-hackathon
cachix push msdqn result-infra
cachix push msdqn result-qrcampaign
-37
View File
@@ -1,37 +0,0 @@
name: Test and Build
on:
push:
branches: ['develop']
pull_request:
branches: ['develop']
env:
NODE_VERSION: 22.14.0
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Set env vars
run: |
echo "CMS_SECRET=${{ secrets.CMS_SECRET }}" >> $GITHUB_ENV
echo "CMS_STORAGE_REGION=${{ secrets.CMS_STORAGE_REGION }}" >> $GITHUB_ENV
echo "CMS_STORAGE_ENDPOINT=${{ secrets.CMS_STORAGE_ENDPOINT }}" >> $GITHUB_ENV
echo "CMS_STORAGE_ACCESS_KEY_ID=${{ secrets.CMS_STORAGE_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "CMS_STORAGE_SECRET_ACCESS_KEY=${{ secrets.CMS_STORAGE_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
echo "CMS_POSTGRES_URL=${{ secrets.CMS_POSTGRES_URL }}" >> $GITHUB_ENV
- name: Nx Build
run: npx nx run-many --target=build --all
+4
View File
@@ -66,3 +66,7 @@ out
.github/instructions/nx.instructions.md
.env.local
# Nix
.direnv
result
-28
View File
@@ -1,28 +0,0 @@
# path to a directory with all packages
storage: ../tmp/local-registry/storage
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
maxage: 60m
packages:
'**':
# give all users (including non-authenticated users) full access
# because it is a local registry
access: $all
publish: $all
unpublish: $all
# if package is not available locally, proxy requests to npm registry
proxy: npmjs
# log settings
log:
type: stdout
format: pretty
level: warn
publish:
allow_offline: true # set offline to true to allow publish offline
-17
View File
@@ -1,17 +0,0 @@
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NX_DAEMON=false
RUN npm run qrcampaign:build
FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist/apps/qrcampaign /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
-9
View File
@@ -1,9 +0,0 @@
services:
backoffice:
build:
context: .
dockerfile: docker/backoffice.Dockerfile
ports:
- '127.0.0.1:3001:80'
restart: unless-stopped
container_name: backoffice
-9
View File
@@ -1,9 +0,0 @@
services:
dimentorin:
build:
context: .
dockerfile: docker/dimentorin.Dockerfile
ports:
- '127.0.0.1:3002:80'
restart: unless-stopped
container_name: dimentorin
-9
View File
@@ -1,9 +0,0 @@
services:
gacha:
build:
context: .
dockerfile: docker/gacha.Dockerfile
ports:
- '127.0.0.1:3003:80'
restart: unless-stopped
container_name: gacha
-17
View File
@@ -1,17 +0,0 @@
services:
hackathon:
build:
context: .
dockerfile: docker/hackathon.Dockerfile
args:
- VITE_SUPABASE_URL=${VITE_SUPABASE_URL}
- VITE_SUPABASE_ANON_KEY=${VITE_SUPABASE_ANON_KEY}
ports:
- '127.0.0.1:3004:80'
restart: unless-stopped
container_name: hackathon
env_file:
- .env.local
environment:
- VITE_SUPABASE_URL=${VITE_SUPABASE_URL}
- VITE_SUPABASE_ANON_KEY=${VITE_SUPABASE_ANON_KEY}
-9
View File
@@ -1,9 +0,0 @@
services:
landing:
build:
context: .
dockerfile: docker/landing.Dockerfile
ports:
- '127.0.0.1:3005:3000'
restart: unless-stopped
container_name: landing
-9
View File
@@ -1,9 +0,0 @@
services:
qrcampaign:
build:
context: .
dockerfile: docker/qrcampaign.Dockerfile
ports:
- '127.0.0.1:3006:80'
restart: unless-stopped
container_name: qrcampaign
-17
View File
@@ -1,17 +0,0 @@
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NX_DAEMON=false
RUN npm run backoffice:build
FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist/apps/backoffice /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
-17
View File
@@ -1,17 +0,0 @@
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NX_DAEMON=false
RUN npm run dimentorin:build
FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist/apps/dimentorin /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
-17
View File
@@ -1,17 +0,0 @@
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NX_DAEMON=false
RUN npm run gacha:build
FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist/apps/gacha /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
-26
View File
@@ -1,26 +0,0 @@
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Accept build arguments
ARG VITE_SUPABASE_URL
ARG VITE_SUPABASE_ANON_KEY
# Set environment variables for build
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
ENV NX_DAEMON=false
RUN npm run hackathon:build
FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist/apps/hackathon /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
-19
View File
@@ -1,19 +0,0 @@
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
COPY . .
ENV NX_DAEMON=false
RUN npm run landing:build
FROM node:22-alpine AS runner
WORKDIR /app
COPY --from=builder /app/dist/apps/landing/.next/standalone .
COPY --from=builder /app/dist/apps/landing/public apps/landing/public
COPY --from=builder /app/dist/apps/landing/.next/static dist/apps/landing/.next/static
EXPOSE 3000
ENTRYPOINT ["node", "apps/landing/server.js"]
-17
View File
@@ -1,17 +0,0 @@
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --prefer-offline --no-audit --no-fund
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NX_DAEMON=false
RUN npm run qrcampaign:build
FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist/apps/qrcampaign /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Generated
+3 -3
View File
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1769170682,
"narHash": "sha256-oMmN1lVQU0F0W2k6OI3bgdzp2YOHWYUAw79qzDSjenU=",
"lastModified": 1774709303,
"narHash": "sha256-D3Q07BbIA2KnTcSXIqqu9P586uWxN74zNoCH3h2ESHg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c5296fdd05cfa2c187990dd909864da9658df755",
"rev": "8110df5ad7abf5d4c0f6fb0f8f978390e77f9685",
"type": "github"
},
"original": {
+69 -60
View File
@@ -6,15 +6,20 @@
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
# NPM dependencies hash (update with: nix run nixpkgs#prefetch-npm-deps -- package-lock.json)
npmDepsHash = "sha256-6O36QDvjiD7j5MgBhID3+5IeJ47MUeK/025ZTKD0ltU=";
# Import helpers
mkViteApp = import ./nix/mkViteApp.nix {
inherit pkgs npmDepsHash;
src = ./.;
@@ -25,62 +30,54 @@
src = ./.;
};
in {
in
{
packages = {
# Static Vite apps
backoffice = mkViteApp { name = "backoffice"; buildScript = "backoffice:build"; };
gacha = mkViteApp { name = "gacha"; buildScript = "gacha:build"; };
dimentorin = mkViteApp { name = "dimentorin"; buildScript = "dimentorin:build"; };
hackathon = mkViteApp { name = "hackathon"; buildScript = "hackathon:build"; };
infra = mkViteApp { name = "infra"; buildScript = "infra:build"; };
qrcampaign = mkViteApp { name = "qrcampaign"; buildScript = "qrcampaign:build"; };
# Next.js app
backoffice = mkViteApp {
name = "backoffice";
buildScript = "backoffice:build";
};
gacha = mkViteApp {
name = "gacha";
buildScript = "gacha:build";
};
dimentorin = mkViteApp {
name = "dimentorin";
buildScript = "dimentorin:build";
};
hackathon = mkViteApp {
name = "hackathon";
buildScript = "hackathon:build";
};
infra = mkViteApp {
name = "infra";
buildScript = "infra:build";
};
qrcampaign = mkViteApp {
name = "qrcampaign";
buildScript = "qrcampaign:build";
};
landing = landingApp;
# Default package
default = self.packages.${system}.landing;
};
# Development shell
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs
nodePackages.npm
nodejs_22
bun
# Useful dev tools
git
jq
];
shellHook = ''
echo "🚀 Imphnen Frontend Development Shell"
echo "Node.js: $(node --version)"
echo "npm: $(npm --version)"
echo ""
echo "Available commands:"
echo " npm install - Install dependencies"
echo " nx dev <app> - Start development server"
echo " nx build <app> - Build an app"
echo ""
echo "Apps: landing, backoffice, gacha, dimentorin, hackathon, qrcampaign"
echo ""
echo "Build packages with:"
echo " nix build .#landing"
echo " nix build .#backoffice"
echo " nix build .#gacha"
echo " nix build .#dimentorin"
echo " nix build .#hackathon"
echo " nix build .#qrcampaign"
export PATH="$PWD/node_modules/.bin:$PATH"
'';
};
}
) // {
# NixOS modules for deployment
)
// {
nixosModules = {
landing = import ./nix/modules/landing.nix { inherit self; };
backoffice = import ./nix/modules/static-app.nix { inherit self; } { appName = "backoffice"; };
gacha = import ./nix/modules/static-app.nix { inherit self; } { appName = "gacha"; };
dimentorin = import ./nix/modules/static-app.nix { inherit self; } { appName = "dimentorin"; };
@@ -88,21 +85,26 @@
infra = import ./nix/modules/static-app.nix { inherit self; } { appName = "infra"; };
qrcampaign = import ./nix/modules/static-app.nix { inherit self; } { appName = "qrcampaign"; };
# All-in-one module that enables all apps
all = { config, lib, pkgs, ... }: {
imports = [
self.nixosModules.landing
self.nixosModules.backoffice
self.nixosModules.gacha
self.nixosModules.dimentorin
self.nixosModules.hackathon
self.nixosModules.infra
self.nixosModules.qrcampaign
];
};
all =
{
config,
lib,
pkgs,
...
}:
{
imports = [
self.nixosModules.landing
self.nixosModules.backoffice
self.nixosModules.gacha
self.nixosModules.dimentorin
self.nixosModules.hackathon
self.nixosModules.infra
self.nixosModules.qrcampaign
];
};
};
# Overlay for easy integration
overlays.default = final: prev: {
imphnen = {
landing = self.packages.${final.system}.landing;
@@ -112,12 +114,19 @@
hackathon = self.packages.${final.system}.hackathon;
infra = self.packages.${final.system}.infra;
qrcampaign = self.packages.${final.system}.qrcampaign;
# Function to build hackathon with custom environment variables (e.g., Supabase)
mkHackathonWithEnv = envVars: import ./nix/mkViteApp.nix {
pkgs = final;
src = self;
npmDepsHash = "sha256-6O36QDvjiD7j5MgBhID3+5IeJ47MUeK/025ZTKD0ltU=";
} { name = "hackathon"; buildScript = "hackathon:build"; inherit envVars; };
mkHackathonWithEnv =
envVars:
import ./nix/mkViteApp.nix
{
pkgs = final;
src = self;
npmDepsHash = "sha256-6O36QDvjiD7j5MgBhID3+5IeJ47MUeK/025ZTKD0ltU=";
}
{
name = "hackathon";
buildScript = "hackathon:build";
inherit envVars;
};
};
};
};
-89
View File
@@ -1,89 +0,0 @@
# Example: How to use in imphnen-infrastructure
#
# In your imphnen-infrastructure flake.nix:
#
# {
# inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# imphnen-frontend = {
# url = "github:your-org/imphnen-frontend-service";
# # Or use local path during development:
# # url = "path:/path/to/imphnen-frontend-service";
# };
# };
#
# outputs = { self, nixpkgs, imphnen-frontend, ... }: {
# nixosConfigurations.your-server = nixpkgs.lib.nixosSystem {
# system = "x86_64-linux";
# modules = [
# # Import all modules at once
# imphnen-frontend.nixosModules.all
#
# # Or import individually:
# # imphnen-frontend.nixosModules.landing
# # imphnen-frontend.nixosModules.backoffice
#
# ./your-server-config.nix
# ];
# };
# };
# }
#
# Then in your-server-config.nix:
{ config, pkgs, ... }:
{
# Enable Landing (Next.js) - runs as systemd service
services.imphnen-landing = {
enable = true;
port = 3000;
hostname = "0.0.0.0";
openFirewall = true;
# environmentFile = /run/secrets/landing-env; # For secrets
};
# Enable Backoffice (Static) - served by nginx
services.imphnen-backoffice = {
enable = true;
domain = "backoffice.imphnen.dev";
enableSSL = true;
};
# Enable Gacha (Static)
services.imphnen-gacha = {
enable = true;
domain = "gacha.imphnen.dev";
enableSSL = true;
};
# Enable Dimentorin (Static)
services.imphnen-dimentorin = {
enable = true;
domain = "dimentorin.imphnen.dev";
enableSSL = true;
};
# Enable Hackathon (Static)
services.imphnen-hackathon = {
enable = true;
domain = "hackathon.imphnen.dev";
enableSSL = true;
};
# Nginx reverse proxy for landing (if needed)
services.nginx.virtualHosts."imphnen.dev" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:3000";
proxyWebsockets = true;
};
};
# Enable ACME for SSL
security.acme = {
acceptTerms = true;
defaults.email = "admin@imphnen.dev";
};
}
+2 -3
View File
@@ -10,8 +10,7 @@ pkgs.buildNpmPackage {
makeCacheWritable = true;
nativeBuildInputs = with pkgs; [
nodejs
nodePackages.npm
nodejs_22
python3 # Required for node-gyp (sharp, etc.)
];
@@ -48,7 +47,7 @@ pkgs.buildNpmPackage {
cat > $out/bin/imphnen-landing <<EOF
#!${pkgs.bash}/bin/bash
cd $out/share/landing
exec ${pkgs.nodejs}/bin/node --jitless apps/landing/server.js "\$@"
exec ${pkgs.nodejs_22}/bin/node --jitless apps/landing/server.js "\$@"
EOF
chmod +x $out/bin/imphnen-landing
+1 -2
View File
@@ -12,8 +12,7 @@ pkgs.buildNpmPackage {
makeCacheWritable = true;
nativeBuildInputs = with pkgs; [
nodejs
nodePackages.npm
nodejs_22
util-linux # For script command to create pseudo-terminal
];
-1
View File
@@ -133,7 +133,6 @@
"tw-animate-css": "^1.2.8",
"typescript": "5.9.3",
"typescript-eslint": "8.40.0",
"verdaccio": "^6.0.5",
"vite": "7.1.3",
"vite-plugin-dts": "~4.5.0",
"vitest": "^3.0.8"
+1 -11
View File
@@ -1,14 +1,4 @@
{
"name": "@imphnen-frontend-service/source",
"$schema": "node_modules/nx/schemas/project-schema.json",
"targets": {
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
}
}
"$schema": "node_modules/nx/schemas/project-schema.json"
}
-8
View File
@@ -1,8 +0,0 @@
{
"routes": [
{
"src": "/[^.]+",
"dest": "/"
}
]
}