Skip to content

Commit

Permalink
Merge pull request #8 from marmelab/feat/gh-pages-deploy
Browse files Browse the repository at this point in the history
Feat(ops): Add deploy script
  • Loading branch information
jonathanarnault authored Aug 5, 2024
2 parents c6c2215 + 1b05668 commit da5bb5d
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 38 deletions.
86 changes: 51 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# React-admin CRM
# Atomic CRM

This is a demo of the [react-admin](https://github.com/marmelab/react-admin) library for React.js. It's a CRM for a fake Web agency with a few sales. You can test it online at https://marmelab.com/react-admin-crm.

Expand All @@ -8,67 +8,83 @@ React-admin usually requires a REST/GraphQL server to provide data. In this demo

To explore the source code, start with [src/App.tsx](https://github.com/marmelab/react-admin/blob/master/examples/crm/src/App.tsx).

**Note**: This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).

## Setup

After having cloned the react-admin repository, run the following command at the project root:
To run this project you will need the following tools installed on your computer:
- Make
- Node 20 LTS
- NPM
- Docker (required by supabase)

After having cloned the [`atomic-crm` repository](https://github.com/marmelab/atomic-crm), run the following command at the project root to install dependencies:

```sh
npm install
make install
```

Then you can start the stack in development mode with the following command:
```sh
make start
```

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>
You will also see any lint errors in the console.
It will start the vite dev server and the local supabase instance. You can then access the app via [`http://localhost:5173/`](http://localhost:5173/).

### `npm test`

Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](#running-tests) for more information.
## Remote Instance Setup

### `npm run build`
You can create a remote supabase using the following script:
```sh
make supabase-remote-init
```

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The script will prompt your for the project configuration and will apply migrations and deploy edge functions.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

### `npm run deploy`
## Manual Remove Instance Link

Create a remote Supabase project and initialize it with the migrations.
If you already created the supabase instance, you can link the instance manually using the following commands:

## Manual Deployment
First, login into your supabase account:

To deploy this application, you need a Supabase instance.
```sh
npx supabase login
```

Login into your supabase account:
Now, link this project to the local supabase instance. You'll be asked to enter the database password.
```sh
npx supabase link --project-ref ********************
```

Then, apply the migrations on it:
```sh
npx supabase login
npx supabase db push
npx supabase functions deploy
```

Then, create a new supabase project. Keep note of the database password you'll have to enter and of the supabase project reference.
Finally, create the `.env.production.local` file with your supabase configuration:

```sh
npx supabase projects create react-admin-crm
VITE_SUPABASE_URL=<instance_url>
VITE_SUPABASE_ANON_KEY=<instance_anon_token>
```

Now, link this project to the local supabase instance. You'll be asked to enter the database password.
## Deploy Updates

If you want to deploy a new version of your CRM, you can run the following command:
```sh
supabase link --project-ref ********************
make prod-deploy
```

Finally, apply the migrations on it:
It will apply migrations, deploy edge functions and push the built applications to the `gh-pages` branch.

## Test Production Mode

If you want to test you application in production mode using the remote supabase instance, you can run the following command:
```sh
supabase db push
make prod-start
```

Note: It will apply migrations and deploy edge functions.

You can then access the app via [`http://localhost:3000/`](http://localhost:3000/).
10 changes: 9 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ stop: stop-supabase ## stop the stack locally
build: ## build the app
npm run build

start-prod: build
prod-start: build supabase-deploy
open http://127.0.0.1:3000 && npx serve -l tcp://127.0.0.1:3000 dist

prod-deploy: build supabase-deploy
npm run ghpages:deploy

supabase-remote-init:
npm run supabase:remote:init
$(MAKE) supabase-deploy

supabase-deploy:
npx supabase db push
npx supabase functions deploy
Loading

0 comments on commit da5bb5d

Please sign in to comment.