-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
79 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# It needs to be node. Prisma still depends on something from node | ||
# to generate the client. | ||
FROM node:slim as base | ||
FROM node:20-slim as base | ||
|
||
# Install OpenSSL. Required for prisma to work. | ||
RUN apt-get update -y && apt-get install -y openssl | ||
|
@@ -13,10 +13,14 @@ RUN npm install -g [email protected] | |
FROM base as installer | ||
# install with devDependencies to be used later | ||
RUN mkdir -p /temp/dev | ||
|
||
COPY package.json bun.lockb /temp/dev/ | ||
COPY /apps/api/package.json /temp/dev/apps/api/package.json | ||
COPY /apps/website/package.json /temp/dev/apps/website/package.json | ||
RUN cd /temp/dev && bun install --frozen-lockfile --ignore-scripts | ||
|
||
RUN --mount=type=cache,id=buncache,target=/root/.bun/install/cache\ | ||
cd /temp/dev &&\ | ||
bun install --frozen-lockfile --ignore-scripts | ||
|
||
# install with --production (exclude devDependencies) | ||
RUN mkdir -p /temp/prod | ||
|
@@ -25,30 +29,32 @@ COPY /apps/api/package.json /temp/prod/apps/api/package.json | |
# We need to include the website package.json because otherwise it will throw | ||
# an error due to a difference between lockfiles | ||
COPY /apps/website/package.json /temp/prod/apps/website/package.json | ||
RUN cd /temp/prod && bun install --frozen-lockfile --production --ignore-scripts | ||
RUN --mount=type=cache,id=buncache,target=/root/.bun/install/cache\ | ||
cd /temp/prod &&\ | ||
bun install --frozen-lockfile --ignore-scripts --production | ||
|
||
# ------------------------------ # | ||
FROM base as prerelease | ||
ENV NODE_ENV=production | ||
|
||
COPY --from=installer /temp/dev/node_modules node_modules | ||
|
||
COPY . . | ||
|
||
RUN bun run build --filter=taco-api | ||
RUN cd ./apps/api && bunx prisma generate | ||
|
||
# ------------------------------ # | ||
FROM base AS release | ||
|
||
ENV NODE_ENV=production | ||
|
||
COPY --from=installer /temp/prod/node_modules /app/node_modules | ||
# Includes the prisma client generated | ||
COPY --from=prerelease /app/node_modules/.prisma /app/node_modules/.prisma | ||
# Includes the database and schema | ||
COPY --from=prerelease /app/apps/api/src/infrastructure/prisma /app/src/infrastructure/prisma | ||
COPY --from=prerelease /app/apps/api/dist/app.js . | ||
COPY --from=prerelease /app/apps/api/prisma /app/prisma | ||
COPY --from=prerelease /app/apps/api/tsconfig.json /app/tsconfig.json | ||
COPY --from=prerelease /app/apps/api/dist /app/dist | ||
COPY --from=prerelease /app/apps/api/package.json . | ||
|
||
# run the app | ||
EXPOSE 4000 | ||
ENTRYPOINT [ "bun", "run", "app.js" ] | ||
ENTRYPOINT bun run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# It needs to be node. Prisma still depends on something from node | ||
# to generate the client. | ||
FROM node:slim as base | ||
FROM node:20-slim as base | ||
|
||
# Install OpenSSL. Required for prisma to work. | ||
RUN apt-get update -y && apt-get install -y openssl | ||
|
@@ -13,10 +13,11 @@ RUN npm install -g [email protected] | |
COPY package.json bun.lockb ./ | ||
COPY /apps/api/package.json /app/apps/api/package.json | ||
COPY /apps/website/package.json /app/apps/website/package.json | ||
RUN bun install --ignore-scripts | ||
|
||
RUN --mount=type=cache,id=buncache,target=/root/.bun/install/cache\ | ||
bun install --frozen-lockfile --ignore-scripts | ||
|
||
COPY . . | ||
|
||
RUN cd ./apps/api && bunx prisma generate | ||
EXPOSE 4000 | ||
ENTRYPOINT bun run dev --filter=taco-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
generator client { | ||
provider = "prisma-client-js" | ||
output = "../dist/generated" | ||
} | ||
|
||
datasource db { | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ | |
"paths": { | ||
"@/*": [ | ||
"src/*" | ||
], | ||
"@prisma/client": [ | ||
"dist/generated" | ||
] | ||
}, | ||
"types": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,21 @@ title: "Getting Started" | |
|
||
Before you start the initial setup, you need to have 2 runtimes installed: | ||
|
||
- [NodeJS](https://nodejs.org/en) version 18 or higher | ||
- [NodeJS](https://nodejs.org/en) version 20 or higher | ||
- [Bun](https://bun.sh/) version 1.0.18 or higher | ||
|
||
Although Bun is the primary runtime, one of the dependencies ([Prisma](https://www.prisma.io/)) still requires Node to generate the initial files. | ||
|
||
:::tip | ||
|
||
If you already have Node installed, you can install `bun` via npm: | ||
|
||
```bash | ||
npm install -g [email protected] | ||
``` | ||
|
||
::: | ||
|
||
## Configuration | ||
|
||
You can either fork this project or clone it, the choice is yours. | ||
|
@@ -31,30 +41,24 @@ This means that to run the server from the project root, you need to run: | |
bun run dev --filter=taco-api | ||
``` | ||
|
||
Or, if you prefer, navigate to the API folder: | ||
|
||
```bash | ||
cd apps/api | ||
``` | ||
|
||
And run the commands directly from the project directory: | ||
|
||
```bash | ||
bun run dev | ||
``` | ||
|
||
In both cases, after running the `dev` command, the API will be running at `http://localhost:4000/graphql`. | ||
|
||
## Running the Server with Docker | ||
|
||
If you want a fully configured environment, it's also possible to run the project via Docker. | ||
|
||
For this, at the project root, run the command: | ||
|
||
```bash | ||
docker compose -f ./apps/api/docker-compose.yml up --build | ||
docker-compose -f ./apps/api/docker-compose.yml up | ||
``` | ||
|
||
:::note | ||
The docker-compose is configured to run the API in development mode. To deploy as a docker image, visit the section [Deploy > Docker](/deploy-docker) | ||
::: | ||
|
||
## Running the Documentation | ||
|
||
If you want to edit the documentation, in the project's root directory, run the command: | ||
|
||
```bash | ||
bun run dev --filter=website | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,21 @@ title: "Começando" | |
|
||
Antes de fazer a configuração inicial, você precisa ter 2 runtimes instalados: | ||
|
||
- [NodeJS](https://nodejs.org/en) versão 18 ou superior | ||
- [NodeJS](https://nodejs.org/en) versão 20 ou superior | ||
- [Bun](https://bun.sh/) versão 1.0.18 ou superior | ||
|
||
Apesar do Bun ser o runtime principal, uma das dependências ([Prisma](https://www.prisma.io/)) ainda precisa do Node para gerar os arquivos iniciais. | ||
|
||
:::tip | ||
|
||
Caso já tenha o Node instalado, você pode o `bun` via npm: | ||
|
||
```bash | ||
npm install -g [email protected] | ||
``` | ||
|
||
::: | ||
|
||
## Configuração | ||
|
||
Você pode tanto fazer um fork deste projeto quanto cloná-lo, fica a seu critério. | ||
|
@@ -31,30 +41,26 @@ Isso significa que para rodar o servidor através da raiz do projeto, você prec | |
bun run dev --filter=taco-api | ||
``` | ||
|
||
Ou, se preferir, navegue até a pasta da API: | ||
|
||
```bash | ||
cd apps/api | ||
``` | ||
|
||
E rode os comandos diretamente do diretório do projeto: | ||
|
||
```bash | ||
bun run dev | ||
``` | ||
|
||
Em ambos os casos, depois de rodar o comando `dev`, a API estará rodando em `http://localhost:4000/graphql`. | ||
Esse comando vai gerar os arquivos necessarios e iniciar o servidor HTTP da API no endereço [http://localhost:4000/graphql](http://localhost:4000/graphql) | ||
|
||
## Rodando o servidor com Docker | ||
|
||
Caso você queira um ambiente já totalmente configurado, também é possível rodar o projeto via Docker. | ||
Caso queira um ambiente totalmente configurado sem precisar instalar nada, é possível rodar o projeto via docker. | ||
|
||
Para isso, na raiz do projeto, rode o comando: | ||
|
||
```bash | ||
docker compose -f ./apps/api/docker-compose.yml up --build | ||
docker-compose -f ./apps/api/docker-compose.yml up | ||
``` | ||
|
||
:::note | ||
O docker-compose está configurado para rodar a API em modo de desenvolvimento. Para fazer o deploy como uma imagem docker, acesse a seção [Deploy > Docker](/deploy-docker) | ||
::: | ||
|
||
## Rodando a documentação | ||
|
||
Caso queira editar a documentação, na raíz do projeto rode o comando: | ||
|
||
```bash | ||
bun run dev --filter=website | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters