Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from clementvtrd/feat/google-oauth
Browse files Browse the repository at this point in the history
feat: google oauth
  • Loading branch information
clementvtrd authored Jun 9, 2024
2 parents f5aa45a + b406e04 commit d979570
Show file tree
Hide file tree
Showing 35 changed files with 697 additions and 148 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
on:
push:
branches-ignore:
- main
tags-ignore:
- v*

jobs:
ci-cd:
name: CI/CD

runs-on: ubuntu-latest

env:
COMPOSE_FILE: docker-compose.test.yaml

steps:
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4

- name: Initialize environment
run: task init-env

- name: Build images
run: task docker-build

- name: lint
run: docker compose run --no-deps --rm app npm run lint

- name: Types checking
run: docker compose run --no-deps --rm app npm run type-check
23 changes: 0 additions & 23 deletions .github/workflows/test.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Taskfile

/.task
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,64 @@
[![.github/workflows/test.yaml](https://github.com/clementvtrd/nextjs-fullstack/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/clementvtrd/nextjs-fullstack/actions/workflows/test.yaml)

# NextJS Fullstack

## Installation

> This project was built around Docker version 25.0 and Docker Compose plugin version 2.27.
### Taskfile

A `Taskfile.yml`is present at the root of the repository which containers the common commands to bootstrap the project. Subfiles stands in the directory `tasks` and are imported at the beginning of the main file.

You can install the `task` CLI through their website at [taskfile.dev/installation](https://taskfile.dev/installation/).

### Boostrap

To bootstrap the project, first run the `init` command:

```sh
task init
```

This will copy the default .env, build images and install NodeJS dependencies.

You needs to update the [.env.local](./app/.env.local) with the following information:

- `AUTH_SECRET` can be generate with this command:

```sh
docker compose run --rm --no-deps app npx auth secret
```

- `AUTH_GOOGLE_ID` and `AUTH_GOOGLE_SECRET` are available in [Google Cloud Platform](https://console.cloud.google.com) under APIs & Services > Credentials. As of writing those lines, only two possibility remains :

1. use the `KNP Hot Tools (localhost)` for development purpose only ;
2. use the `KNP Hot Tools (prod)` for production server under knpnet.net domain ;

- `AUTH_GOOGLE_RESTRICT_DOMAIN` might be blank during development, so you can loggin with any Google account or with `@knplabs.com` to restrict Google account from KNP Labs.

### Starting containers

Simply run:

```sh
task start
```

## Adminer

You can start Adminer with the following command:

```sh
docker compose --profile adminer up -d adminer
```

## Help

You can si all available shortcuts defined with Taskfile with this command[^1]:

```sh
task --list
```

[^1]: Only shortcuts with a description (`desc`) are displayed
13 changes: 13 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ tasks:
- init-env
- docker-build
- npm-install

start:
desc: Start the project
deps: [init]
cmds:
- cmd: docker compose up --detach
- task: prisma:deploy
Expand All @@ -20,6 +24,8 @@ tasks:
cmd: cp .env.dist .env.local
ignore_error: true
dir: app
status:
- test -f .env.local

docker-build:
desc: Build the Docker image
Expand All @@ -30,3 +36,10 @@ tasks:
desc: Install the dependencies
deps: [docker-build]
cmd: docker compose run --no-deps --rm app npm install --ci
sources:
- app/package.json
- app/package-lock.json
- app/prisma/schema.prisma
generates:
- app/node_modules/**/*
- app/prisma/generated/**/*
13 changes: 12 additions & 1 deletion app/.env.dist
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
BASE_URL=http://localhost:3000
BASE_URL="http://localhost:3000"

## Prisma

DATABASE_URL="postgresql://postgres:password@postgres:5432/app?schema=public"

## Auth JS

AUTH_SECRET=
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
AUTH_GOOGLE_RESTRICT_DOMAIN=
28 changes: 10 additions & 18 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,23 @@ COPY package.json package-lock.json ./

RUN corepack enable npm && corepack install

FROM npm AS deps

ENV NODE_ENV=production

RUN npm ci

FROM npm AS dev-deps
FROM npm AS development

ENV NODE_ENV=development

RUN npm ci

FROM dev-deps AS test

ENV NODE_ENV=test

COPY . .

RUN npx prisma generate

FROM npm AS development

VOLUME [ "/opt/app/.next" ]

CMD ["npm", "run", "dev"]

FROM npm AS builder

ENV NODE_ENV=production

COPY . .

COPY --from=dev-deps /opt/app/node_modules /opt/app/node_modules
COPY --from=npm /opt/app/node_modules /opt/app/node_modules

RUN npx prisma generate

Expand All @@ -48,6 +34,12 @@ RUN npm run build \
&& cp -r .next/static .next/standalone/.next/ \
&& cp -r public .next/standalone/

FROM builder AS test

ENV NODE_ENV=test

COPY . .

FROM base AS release

ENV NODE_ENV=production
Expand Down
36 changes: 0 additions & 36 deletions app/README.md

This file was deleted.

13 changes: 12 additions & 1 deletion app/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone"
output: "standalone",
transpilePackages: [
"lucide-react",
],
images: {
remotePatterns: [
{
hostname: '*.googleusercontent.com',
protocol: 'https',
}
]
}
};

export default nextConfig;
Loading

0 comments on commit d979570

Please sign in to comment.