Skip to content

Commit dc2e4c3

Browse files
committed
Initial commit of the mono repo
1 parent 604a9d7 commit dc2e4c3

File tree

91 files changed

+3831
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3831
-0
lines changed

.dockerignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
*.log
2+
.git
3+
.github
4+
# editor
5+
.idea
6+
# dependencies
7+
node_modules
8+
.pnp
9+
.pnp.js
10+
11+
# testing
12+
coverage
13+
14+
# next.js
15+
.next/
16+
build
17+
18+
# packages
19+
build
20+
dist
21+
packages/**/dist
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
.turbo
28+
.vercel
29+
.cache
30+
.output
31+
apps/**/public/build
32+
33+
cypress/screenshots
34+
cypress/videos
35+
36+
apps/**/styles/tailwind.css
37+
packages/**/styles/tailwind.css

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*/**.js
2+
*/**.d.ts
3+
packages/*/dist
4+
packages/*/lib

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
root: true,
3+
// This tells ESLint to load the config from the package `eslint-config-custom`
4+
extends: ["custom"],
5+
settings: {
6+
next: {
7+
rootDir: ["apps/*/"],
8+
},
9+
},
10+
parserOptions: {
11+
sourceType: "module",
12+
ecmaVersion: 2020,
13+
},
14+
};

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
postgres-data
4+
# dependencies
5+
node_modules
6+
.pnp
7+
.pnp.js
8+
9+
# testing
10+
coverage
11+
12+
# next.js
13+
.next/
14+
out/
15+
build
16+
dist
17+
packages/**/dist
18+
19+
# Tailwind
20+
apps/**/styles/tailwind.css
21+
packages/**/styles/tailwind.css
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
32+
# local env files
33+
.env.docker
34+
.env.local
35+
.env.development.local
36+
.env.test.local
37+
.env.production.local
38+
39+
# turbo
40+
.turbo
41+
.vercel
42+
.cache
43+
.env
44+
.output
45+
apps/**/public/build

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,67 @@ new Workflow({
105105
},
106106
}).listen();
107107
```
108+
109+
## Development
110+
111+
> **Warning**
112+
> All the following commands should be launched from the **monorepo root directory**
113+
114+
1. Install the dependencies.
115+
```bash
116+
pnpm install
117+
```
118+
You also have to copy the example .env.example:
119+
```sh
120+
cp .env.example .env
121+
cp .env.example .env.docker
122+
```
123+
2. Start the postgresql docker container
124+
```bash
125+
pnpm run docker:db
126+
```
127+
> **Note:** The npm script will complete while Docker sets up the container in the background. Ensure that Docker has finished and your container is running before proceeding.
128+
129+
3. Generate prisma schema
130+
```bash
131+
pnpm run generate
132+
```
133+
4. Run the Prisma migration to the database
134+
```bash
135+
pnpm run db:migrate:deploy
136+
```
137+
5. Run the first build (with dependencies via the `...` option)
138+
```bash
139+
pnpm run build --filter=webapp...
140+
```
141+
**Running simply `pnpm run build` will build everything, including the NextJS app.**
142+
6. Run the Remix dev server
143+
```bash
144+
pnpm run dev --filter=webapp
145+
```
146+
## Tests, Typechecks, Lint, Install packages...
147+
Check the `turbo.json` file to see the available pipelines.
148+
- Run the Cypress tests and Dev
149+
```bash
150+
pnpm run test:e2e:dev --filter=webapp
151+
```
152+
- Lint everything
153+
```bash
154+
pnpm run lint
155+
```
156+
- Typecheck the whole monorepo
157+
```bash
158+
pnpm run typecheck
159+
```
160+
- Test the whole monorepo
161+
```bash
162+
pnpm run test
163+
or
164+
pnpm run test:dev
165+
```
166+
- How to install an npm package in the Remix app ?
167+
```bash
168+
pnpm add dayjs --filter webapp
169+
```
170+
- Tweak the tsconfigs, eslint configs in the `config-package` folder. Any package or app will then extend from these configs.
171+

apps/webapp/.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": [
3+
"@remix-run/eslint-config",
4+
"@remix-run/eslint-config/node",
5+
"prettier"
6+
]
7+
}

apps/webapp/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
3+
/.cache
4+
/build
5+
/public/build
6+
7+
/cypress/screenshots
8+
/cypress/videos
9+
10+
/app/styles/tailwind.css

apps/webapp/.prettierignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
3+
/build
4+
/public/build
5+
.env
6+
7+
/cypress/screenshots
8+
/cypress/videos
9+
/postgres-data
10+
11+
/app/styles/tailwind.css

apps/webapp/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
FROM node:lts-bullseye-slim AS pruner
2+
RUN apt-get update && apt-get install -y openssl
3+
WORKDIR /app
4+
RUN yarn global add turbo
5+
COPY . .
6+
RUN turbo prune --scope=webapp --docker
7+
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
8+
9+
# Base strategy to have layer caching
10+
FROM node:lts-bullseye-slim AS base
11+
RUN apt-get update && apt-get install -y openssl
12+
WORKDIR /app
13+
COPY .gitignore .gitignore
14+
COPY --from=pruner /app/out/json/ .
15+
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
16+
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
17+
# COPY --from=pruner /app/out/full/ .
18+
19+
FROM base AS dev-deps
20+
WORKDIR /app
21+
RUN corepack enable
22+
RUN pnpm install --ignore-scripts --frozen-lockfile
23+
24+
FROM base AS production-deps
25+
WORKDIR /app
26+
RUN corepack enable
27+
ENV NODE_ENV production
28+
RUN pnpm install --prod --frozen-lockfile
29+
COPY --from=pruner /app/out/full/apps/webapp/prisma/schema.prisma /app/apps/webapp/prisma/schema.prisma
30+
RUN pnpx prisma generate --schema /app/apps/webapp/prisma/schema.prisma
31+
32+
FROM base AS builder
33+
WORKDIR /app
34+
RUN corepack enable
35+
ENV NODE_ENV production
36+
COPY --from=pruner /app/out/full/ .
37+
COPY --from=dev-deps /app/ .
38+
COPY turbo.json turbo.json
39+
RUN pnpm run generate
40+
RUN pnpm run build --filter=webapp...
41+
42+
# Runner
43+
FROM node:lts-bullseye-slim AS runner
44+
RUN apt-get update && apt-get install -y openssl
45+
WORKDIR /app
46+
RUN corepack enable
47+
ENV NODE_ENV production
48+
RUN addgroup --system --gid 1001 nodejs
49+
RUN adduser --system --uid 1001 remixjs
50+
RUN chown -R remixjs:nodejs /app
51+
USER remixjs
52+
53+
COPY --from=pruner --chown=remixjs:nodejs /app/out/full/ .
54+
COPY --from=production-deps --chown=remixjs:nodejs /app .
55+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/app/styles/tailwind.css ./apps/webapp/app/styles/tailwind.css
56+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/build/server.js ./apps/webapp/build/server.js
57+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/build ./apps/webapp/build
58+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/public ./apps/webapp/public
59+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/prisma/schema.prisma ./apps/webapp/build/schema.prisma
60+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/prisma/migrations ./apps/webapp/build/migrations
61+
COPY --from=builder --chown=remixjs:nodejs /app/apps/webapp/node_modules/.prisma/client/libquery_engine-debian-openssl-1.1.x.so.node ./apps/webapp/build/libquery_engine-debian-openssl-1.1.x.so.node
62+
63+
# release_command = "pnpx prisma migrate deploy --schema apps/webapp/prisma/schema.prisma"
64+
CMD ["pnpm", "--filter", "webapp", "run", "start"]

apps/webapp/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## API Hero webapp - powered by Remix
2+
3+
To start, run with `pnpm run dev --filter webapp`
4+
5+
### Build the docker image locally:
6+
7+
```sh
8+
pnpm run docker:build:webapp
9+
docker run -it apihero-webapp sh
10+
```

0 commit comments

Comments
 (0)