Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(zerops): Bump remix version & add future flags #508

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions zerops/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
# Zerops + Remix - Nodejs - [Preview](https://remixrun.zerops.dev/)
# Zerops x Remix - Node.js

![Header Image](header.png)
![remix](https://github.com/zeropsio/recipe-shared-assets/raw/main/covers/svg/cover-remix.svg)

A nodejs Remix example for Zerops which you can deploy in 2 simple steps.
Remix is a framework for fast, dynamic web apps with server-side rendering. [Zerops](https://zerops.io) simplifies deployment, offering automatic scaling, optional caching, logging integrations, and easy setup for additional services, letting you focus on development without infrastructure hassles.

## Instructions to Deploy on Zerops
<br/>

1. Navigate to the Zerops Dashboard and locate the import project button on the sidebar.
## Deploy to Zerops

2. Paste the Project Yaml
You can either click the deploy button to deploy directly on Zerops, or manually copy the [import yaml](https://github.com/zeropsio/recipe-remix-nodejs/blob/main/zerops-project-import.yml) to the import dialog in the Zerops app.

```yaml
project:
name: zerops-remix
[![Deploy on Zerops](https://github.com/zeropsio/recipe-shared-assets/blob/main/deploy-button/green/deploy-button.svg)](https://app.zerops.io/recipe/remix-nodejs)

services:
- hostname: remixnode
type: nodejs@18
buildFromGit: https://github.com/fxck/zerops-remix-nodejs
ports:
- port: 3000
httpSupport: true
enableSubdomainAccess: true
minContainers: 1
```
<br/>
<br/>

If you still find yourself stuck in the process join our [Discord community](https://discord.gg/5ptAqtpyvh).
## Recipe features
A Node.js version of Remix v2 running on a load balanced **Zerops Node.js** service.

<br/>

## Production vs. development
This recipe is ready for production as is, and will scale horizontally by adding more containers in case of high traffic surges. If you want to achieve the highest baseline reliability and resiliace, start with at least two containers (add `minContainers: 2` in recipe YAML in the `app` service section, or change the minimum containers in "Automatic Scaling configuration" section of service detail).

Additionally for you might want to consider:
- Using **Zerops Redis** service for caching
- Setting up [Winston](https://github.com/winstonjs/winston) for advanced and structured logging

<br/>

## Changes made over the default installation
If you want to modify your existing Remix app to efficiently run on Zerops, there are no changes needed in the codebase on top of the standard installation, just add [zerops.yml](https://github.com/zeropsio/recipe-remix-nodejs/blob/main/zerops.yml) to your repository.

<br/>
<br/>

Need help setting your project up? Join [Zerops Discord community](https://discord.com/invite/WDvCZ54).
Binary file removed zerops/header.png
Binary file not shown.
15 changes: 8 additions & 7 deletions zerops/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
"scripts": {
"build": "remix vite:build",
"dev": "remix vite:dev",
"start": "cross-env NODE_ENV=production node ./server.js"
"start": "cross-env NODE_ENV=production node ./server.js",
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/express": "^2.8.1",
"@remix-run/node": "^2.8.1",
"@remix-run/react": "^2.8.1",
"@remix-run/express": "^2.9.2",
"@remix-run/node": "^2.9.2",
"@remix-run/react": "^2.9.2",
"compression": "^1.7.4",
"express": "^4.18.2",
"isbot": "^4.1.0",
"express": "^4.19.2",
"isbot": "^5.1.9",
"morgan": "^1.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.3.1"
},
"devDependencies": {
"@remix-run/dev": "^2.8.1",
Expand Down
11 changes: 10 additions & 1 deletion zerops/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@ import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
plugins: [remix(), tsconfigPaths()],
plugins: [
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
},
}),
tsconfigPaths(),
],
});
51 changes: 9 additions & 42 deletions zerops/zerops.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,18 @@
zerops:
# supports monorepositories, just add
# one setup section after the other
- setup: remixnode
# ==== how to build your application ====
- setup: app
build:
# select what technology should the
# build container be based on, can
# be different from service technology
# see docs for full list
base: nodejs@20

# *optional* add additional dependencies
# on top of base technology (combination
# will be cached for next build)
# prepareCommands:
# - apt-get something

# build your application
buildCommands:
- npm i
- npm run build

# select which files / folders to deploy
# after the build succesfully finished
deploy:
- pnpm i
- pnpm run build
deployFiles:
- build
- server.js
- package.json
- node_modules

# *optional*: which files / folders
# to cache for the next use
cache:
- node_modules
- package-lock.json

# ==== how to run your application ====
run:
# *optional* install dependencies that your
# runtime service requires (will be cached)
# prepareCommands:
# - apt-get something

# *optional*: triggered before each start/restart
# of your application, to eg. clean cache
# initCommands:
# - rm -rf ./cache

# how to start your application
start: npm start
base: nodejs@20
ports:
- port: 3000
httpSupport: true
start: pnpm start