diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 6791ab4..0000000 --- a/.dockerignore +++ /dev/null @@ -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 diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml index 1de3c6c..571395b 100644 --- a/.github/workflows/nix-build.yml +++ b/.github/workflows/nix-build.yml @@ -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 diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml deleted file mode 100644 index c37a607..0000000 --- a/.github/workflows/test-build.yml +++ /dev/null @@ -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 diff --git a/.gitignore b/.gitignore index 9e91e32..77ba5cb 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,7 @@ out .github/instructions/nx.instructions.md .env.local + +# Nix +.direnv +result diff --git a/.verdaccio/config.yml b/.verdaccio/config.yml deleted file mode 100644 index f74420f..0000000 --- a/.verdaccio/config.yml +++ /dev/null @@ -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 diff --git a/apps/qrcampaign/Dockerfile b/apps/qrcampaign/Dockerfile deleted file mode 100644 index 80582ff..0000000 --- a/apps/qrcampaign/Dockerfile +++ /dev/null @@ -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;"] diff --git a/docker-compose-backoffice.yml b/docker-compose-backoffice.yml deleted file mode 100644 index 738529e..0000000 --- a/docker-compose-backoffice.yml +++ /dev/null @@ -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 diff --git a/docker-compose-dimentorin.yml b/docker-compose-dimentorin.yml deleted file mode 100644 index ae6a152..0000000 --- a/docker-compose-dimentorin.yml +++ /dev/null @@ -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 diff --git a/docker-compose-gacha.yml b/docker-compose-gacha.yml deleted file mode 100644 index 1f73d65..0000000 --- a/docker-compose-gacha.yml +++ /dev/null @@ -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 diff --git a/docker-compose-hackathon.yml b/docker-compose-hackathon.yml deleted file mode 100644 index b04feff..0000000 --- a/docker-compose-hackathon.yml +++ /dev/null @@ -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} diff --git a/docker-compose-landing.yml b/docker-compose-landing.yml deleted file mode 100644 index 04d8f86..0000000 --- a/docker-compose-landing.yml +++ /dev/null @@ -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 diff --git a/docker-compose-qrcampaign.yml b/docker-compose-qrcampaign.yml deleted file mode 100644 index f4e9c8f..0000000 --- a/docker-compose-qrcampaign.yml +++ /dev/null @@ -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 diff --git a/docker/backoffice.Dockerfile b/docker/backoffice.Dockerfile deleted file mode 100644 index 1b8a4fe..0000000 --- a/docker/backoffice.Dockerfile +++ /dev/null @@ -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;"] \ No newline at end of file diff --git a/docker/dimentorin.Dockerfile b/docker/dimentorin.Dockerfile deleted file mode 100644 index e27c16e..0000000 --- a/docker/dimentorin.Dockerfile +++ /dev/null @@ -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;"] \ No newline at end of file diff --git a/docker/gacha.Dockerfile b/docker/gacha.Dockerfile deleted file mode 100644 index 2b1996e..0000000 --- a/docker/gacha.Dockerfile +++ /dev/null @@ -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;"] \ No newline at end of file diff --git a/docker/hackathon.Dockerfile b/docker/hackathon.Dockerfile deleted file mode 100644 index 42e72e1..0000000 --- a/docker/hackathon.Dockerfile +++ /dev/null @@ -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;"] diff --git a/docker/landing.Dockerfile b/docker/landing.Dockerfile deleted file mode 100644 index 8cf6cea..0000000 --- a/docker/landing.Dockerfile +++ /dev/null @@ -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"] \ No newline at end of file diff --git a/docker/qrcampaign.Dockerfile b/docker/qrcampaign.Dockerfile deleted file mode 100644 index 80582ff..0000000 --- a/docker/qrcampaign.Dockerfile +++ /dev/null @@ -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;"] diff --git a/flake.lock b/flake.lock index 77c9736..f123c7e 100644 --- a/flake.lock +++ b/flake.lock @@ -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": { diff --git a/flake.nix b/flake.nix index ccd574c..b329f3e 100644 --- a/flake.nix +++ b/flake.nix @@ -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 - Start development server" - echo " nx build - 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; + }; }; }; }; diff --git a/nix/example-infrastructure.nix b/nix/example-infrastructure.nix deleted file mode 100644 index 592b744..0000000 --- a/nix/example-infrastructure.nix +++ /dev/null @@ -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"; - }; -} diff --git a/nix/landing.nix b/nix/landing.nix index 4284da5..b5db88f 100644 --- a/nix/landing.nix +++ b/nix/landing.nix @@ -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 <