Skip to content

Commit

Permalink
Big project update
Browse files Browse the repository at this point in the history
Fix repo config
Add turbo pipelines
  • Loading branch information
MathieuAndrade committed Mar 24, 2024
1 parent 527e048 commit 6ebe2e8
Show file tree
Hide file tree
Showing 14 changed files with 3,195 additions and 4,179 deletions.
4 changes: 2 additions & 2 deletions .docker/Dockerfile-development
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:18-alpine as base

# System dependencies
RUN apk add --no-cache sqlite make python3 gcc g++ \
&& npm install -g pnpm@8
&& npm install -g pnpm@8 turbo

USER node
WORKDIR /src
Expand All @@ -17,7 +17,7 @@ HEALTHCHECK --interval=1s --retries=3600 \
CMD test -f ./task_finished.txt || exit 1

# Start container
CMD pnpm install && pnpm --filter "./packages/*" build && touch task_finished.txt && sleep 4s
CMD pnpm install && turbo build && touch task_finished.txt && sleep 4s

# Friday server image -------------------------------------
FROM base as server
Expand Down
41 changes: 20 additions & 21 deletions .docker/Dockerfile-production
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
FROM node:18-alpine as base

# System dependencies
RUN npm install -g pnpm@8 http-server cross-env \
&& apk add --no-cache sqlite make curl
RUN apk add --no-cache curl

WORKDIR /src

COPY ../package.json .

CMD pnpm start:prod
CMD npm run start:prod

# builder ------------------------------------------------
FROM base as builder

# System dependencies
RUN apk add --no-cache sqlite make

# Builder dependencies
RUN npm install -g pnpm@8 turbo

WORKDIR /usr/src

COPY ../pnpm-lock.yaml ./
Expand All @@ -23,41 +26,37 @@ COPY ../ ./

RUN pnpm fetch \
&& pnpm install -r \
&& pnpm --filter "./packages/*" build \
&& pnpm build \
&& pnpm --filter "./apps/server" --prod deploy pruned-server
&& turbo build

# Friday front -------------------------------------------
FROM base as front

# Front dependencies
RUN npm install -g http-server

# Add friday core
COPY --from=builder /usr/src/apps/front/dist ./apps/front/dist
COPY --from=builder /usr/src/apps/front/dist ./dist

COPY ../apps/front/package.json ./apps/front/
COPY ../apps/front/package.json ./

ENV NODE_ENV production

# Ping friday to check heartbeat
HEALTHCHECK --interval=10s --retries=5 \
CMD curl --fail "http://localhost:1444" || exit 1

# Export listening port
EXPOSE 1444

# Friday back ------------------------------------------
FROM base as server

# Server dependencies
RUN npm install mqtt sqlite3 ssh2
RUN npm install -g cross-env

# Add friday core
COPY --from=builder /usr/src/apps/server/dist ./apps/server/dist
COPY --from=builder /usr/src/pruned-server/node_modules ./apps/server/node_modules
COPY --from=builder /usr/src/apps/server/dist ./dist

COPY ../apps/server/package.json ./apps/server/
COPY ../apps/server/package.json ./

ENV NODE_ENV production

# Ping friday to check heartbeat @todo : change url for heartbeat url
HEALTHCHECK --interval=10s --retries=5 \
CMD curl --fail "http://localhost:1443/api/v1/user/count" || exit 1

# Export listening port
EXPOSE 1443
15 changes: 2 additions & 13 deletions .docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ services:
server:
container_name: friday-server
image: fridayai/friday-server:latest
labels:
"autoheal": "true"
build:
context: ../
dockerfile: ./.docker/Dockerfile-production
Expand All @@ -31,7 +29,7 @@ services:
- NODE_ENV=production

broker:
container_name: broker
container_name: friday-broker
image: eclipse-mosquitto:latest
restart: always
ports:
Expand All @@ -44,17 +42,8 @@ services:
- TZ=Europe/Paris
user: 1000:1000

autoheal:
container_name: Friday-ai-autoheal
image: willfarrell/autoheal
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
environment:
- AUTOHEAL_INTERVAL=10

watchtower:
container_name: Friday-ai-watchtower
container_name: friday-watchtower
image: containrrr/watchtower
restart: always
volumes:
Expand Down
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ node.d.ts
docker
.github
.pnpm-store
node_modules
node_modules
lib
dist
.turbo
1 change: 0 additions & 1 deletion .env

This file was deleted.

10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This configuration only applies to the package manager root.
/** @type {import("eslint").Linter.Config} */
module.exports = {
ignorePatterns: ["apps/**", "packages/**"],
extends: ["@friday-ai/tools/eslint/base.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
88 changes: 44 additions & 44 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,57 +1,54 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependency directories
# Dependencies
node_modules
jspm_packages
.pnp
.pnp.js
.pnpm-store

# Optional npm cache directory
# Optional cache directory
.npm

# Optional eslint cache
.eslintcache
.turbo

# Local env files
.env
.env.local
.env.development.local
.env.development
.env.test.local
.env.production.local
.env.production
.env.staging

# Testing
coverage
.nyc_output
stats.html

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz
# Turbo
.turbo

# Yarn Integrity file
.yarn-integrity
# Vercel
.vercel

# Build files
dist/
lib/
# Build Outputs
.next/
out/
build
dist
lib
vite.config.*.mjs
.parcel-cache
*.lcov

# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem

# IDE folder
.idea
Expand All @@ -61,3 +58,6 @@ package-lock.json

# Docker folder
/.docker/mosquitto/data/

# Local databases files
*.db
3 changes: 1 addition & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
auto-install-peers=true
node-linker=hoisted
store-dir=.pnpm-store
store-dir=.pnpm-store
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ build:
build --no-cache

prod:
@docker-compose -f docker-compose.yml \
-f docker-compose.prod.yml \
up -d --remove-orphans
@docker-compose -f .docker/docker-compose.prod.yml up -d --remove-orphans

dev:
@docker compose -f docker-compose.yml \
Expand Down
30 changes: 6 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,12 @@
"version": "1.0.0",
"description": "Server and web app of the Friday assistant",
"main": "index.js",
"engines": {
"node": "18.x",
"pnpm": "8.x"
},
"scripts": {
"start": "per-env",
"start:prod": "pnpm --parallel -r --filter \"./apps/*\" start:prod",
"start:dev": "pnpm --parallel -r --filter \"./apps/*\" start:dev",
"install:dev": "pnpm install -r --force",
"build": "pnpm -r build",
"test": "pnpm -r test",
"test:apps": "pnpm -r --filter \"./apps/*\" test",
"test:packages": "pnpm -r --filter \"./packages/*\" test",
"coverage": "pnpm -r --filter \"./apps/*\" coverage",
"coverage:junit": "pnpm -r --filter \"./apps/server\" coverage:junit",
"lint": "pnpm -r lint",
"lint:fix": "pnpm -r lint:fix"
},
"scripts": {},
"keywords": [],
"author": "",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/friday-ai/friday.git"
},
"bugs": {
"url": "https://github.com/friday-ai/friday/issues"
"devDependencies": {
"@friday-ai/tools": "workspace:^",
"turbo": "^1.12.2"
}
}
Loading

0 comments on commit 6ebe2e8

Please sign in to comment.