Skip to content

Commit

Permalink
fix: no more node server
Browse files Browse the repository at this point in the history
  • Loading branch information
JMBeresford committed Sep 4, 2024
1 parent 08cdd41 commit 2d6d1b4
Show file tree
Hide file tree
Showing 171 changed files with 2,030 additions and 2,770 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/publish-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for
- name: Extract metadata for images
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
Expand All @@ -64,7 +64,7 @@ jobs:
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

build-tauri:
build-desktop-clients:
permissions:
contents: write
strategy:
Expand All @@ -73,7 +73,7 @@ jobs:
include:
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin --config tauri.build.conf.json"
- platform: "macos-13" # for Intel based macs.
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin --config tauri.build.conf.json"
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
args: "--config tauri.build.conf.json"
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
choco install -y postgresql
- name: install dependencies (macos only)
if: matrix.platform == 'macos-latest' || matrix.platform == 'macos-13' # This must match the platform value defined above.
if: matrix.platform == 'macos-latest' # This must match the platform value defined above.
run: |
brew install libpq && brew link --force libpq
Expand All @@ -136,7 +136,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
NEXT_PUBLIC_IS_DESKTOP: true
VITE_IS_DESKTOP: true
with:
projectPath: packages/client
tauriScript: pnpm tauri
Expand Down
3 changes: 0 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
hoisted=true
symlink=false
node-linker=hoisted
shell-emulator=true
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: v2
plugins:
- remote: buf.build/community/stephenh-ts-proto
out: packages/client/web/generated
out: packages/client/web/src/generated
opt:
- paths=source_relative
- useDate=false
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ services:
ports:
- 3000:${RETROM_WEB_PORT:-3000}
environment:
NEXT_PUBLIC_RETROM_WEB_PORT: ${RETROM_WEB_PORT:-3000}
NEXT_PUBLIC_RETROM_HOST: ${RETROM_HOST:-retrom:5101}
VITE_RETROM_WEB_PORT: ${RETROM_WEB_PORT:-3000}
VITE_RETROM_HOST: ${RETROM_HOST:-retrom:5101}
depends_on:
- retrom
8 changes: 2 additions & 6 deletions docker/web.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ COPY --from=deps /app/. ./

RUN corepack enable pnpm && pnpm --filter web build

ENV NEXT_TELEMETRY_DISABLED=1

FROM base AS runner
WORKDIR /app

Expand All @@ -41,12 +39,10 @@ RUN addgroup --system --gid $GID retrom
RUN adduser --system --uid $UID retrom


COPY --from=builder --chown=retrom:retrom /app/packages/client/web/.next/standalone ./
COPY --from=builder --chown=retrom:retrom /app/packages/client/web/public ./packages/client/web/public
COPY --from=builder --chown=retrom:retrom /app/packages/client/web/.next/static ./packages/client/web/.next/static
COPY --from=builder --chown=retrom:retrom /app/packages/client/web/dist ./dist

USER retrom

EXPOSE $PORT

CMD HOSTNAME="0.0.0.0" node packages/client/web/server.js
CMD npx vite preview --host --port $PORT
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@tauri-apps/api": "2.0.0-rc.4",
"@tauri-apps/plugin-fs": "2.0.0-beta.5",
"@tauri-apps/plugin-upload": "2.0.0-beta.6",
"typescript": "^5.5"
"typescript": "^5.5.3"
},
"packageManager": "pnpm@9.5.0"
}
3 changes: 1 addition & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"description": "The tauri wrapper for the retrom client",
"type": "module",
"scripts": {
"dev": "NEXT_PUBLIC_IS_DESKTOP=true tauri dev --no-watch",
"prepareNode": "node ./prepare-node.js",
"dev": "VITE_IS_DESKTOP=true tauri dev --no-watch",
"build": "tauri build --config tauri.build.conf.json"
},
"devDependencies": {
Expand Down
53 changes: 0 additions & 53 deletions packages/client/prepare-node.js

This file was deleted.

49 changes: 1 addition & 48 deletions packages/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

use retrom_codegen::retrom::RetromHostInfo;
use std::str;
use tauri::{is_dev, path::BaseDirectory, Manager};
use tauri_plugin_shell::{process::CommandEvent, ShellExt};
use tauri::Manager;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[tauri::command]
Expand Down Expand Up @@ -58,52 +57,6 @@ pub async fn main() {
.plugin(retrom_plugin_installer::init())
.plugin(retrom_plugin_launcher::init().await)
.invoke_handler(tauri::generate_handler![greet])
.setup(|app| {
if is_dev() {
return Ok(());
}

let web_server_path = "web/.next/node-server/packages/client/web/server.js";
let path = app
.path()
.resolve(web_server_path, BaseDirectory::Resource)?;

#[cfg(target_os = "windows")]
let executable = "node.exe";
#[cfg(not(target_os = "windows"))]
let executable = "node";

let cmd = app.shell().sidecar(executable).unwrap().args([path]);

let (mut rx, _) = cmd.spawn().expect("failed to spawn sidecar");

tauri::async_runtime::spawn(async move {
while let Some(event) = rx.recv().await {
match event {
CommandEvent::Stdout(line) => {
if let Ok(s) = str::from_utf8(&line) {
tracing::info!("{}", s)
}
}
CommandEvent::Terminated(payload) => {
if let Some(code) = payload.code {
if code != 0 {
tracing::error!("Node server exited with code: {}", code);
}
}
}
CommandEvent::Stderr(line) => {
if let Ok(s) = str::from_utf8(&line) {
tracing::error!("{}", s)
}
}
_ => {}
}
}
});

Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2 changes: 0 additions & 2 deletions packages/client/tauri.build.conf.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"$schema": "../../node_modules/@tauri-apps/cli/schema.json",
"bundle": {
"externalBin": ["./bin/node"],
"resources": ["web/.next/node-server"],
"macOS": {
"signingIdentity": "-",
"entitlements": "./entitlements.plist.xml"
Expand Down
8 changes: 4 additions & 4 deletions packages/client/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "../../node_modules/@tauri-apps/cli/schema.json",
"build": {
"beforeBuildCommand": "pnpm --shell-emulator --filter=web build:desktop && pnpm prepareNode",
"beforeBuildCommand": "pnpm --shell-emulator --filter=web build:desktop",
"beforeDevCommand": "pnpm --filter=web dev",
"frontendDist": "http://localhost:3000",
"frontendDist": "./web/dist",
"devUrl": "http://localhost:3000"
},
"bundle": {
Expand Down Expand Up @@ -50,10 +50,10 @@
{
"label": "main",
"fullscreen": false,
"height": 600,
"height": 720,
"resizable": true,
"title": "Retrom",
"width": 800
"width": 1280
}
],
"security": {
Expand Down
8 changes: 0 additions & 8 deletions packages/client/web/.eslintrc.json

This file was deleted.

57 changes: 21 additions & 36 deletions packages/client/web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# ssl
ssl/
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# codegen
generated/
19 changes: 0 additions & 19 deletions packages/client/web/app/error.tsx

This file was deleted.

Binary file removed packages/client/web/app/favicon.ico
Binary file not shown.
13 changes: 0 additions & 13 deletions packages/client/web/app/games/[id]/layout.tsx

This file was deleted.

Loading

0 comments on commit 2d6d1b4

Please sign in to comment.