Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding boilerplate #37

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
Binary file added apps/web/bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions apps/web/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- REPLACE janedoe with your mysql user in the .env

GRANT CREATE ON *.* TO 'janedoe'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'janedoe'@'%';
74 changes: 74 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: '3.8'
services:
db:
image: mysql:8.4
container_name: mysql
restart: always
env_file:
- ./apps/web/.env
ports:
- '3306:3306'
healthcheck:
test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --password="$$(cat /run/secrets/db-password)" --silent']
interval: 3s
retries: 5
start_period: 30s
volumes:
- mysql-data:/var/lib/mysql
- ./apps/web/sql/init.sql:/docker-entrypoint-initdb.d/init.sql

prisma:
build:
context: .
dockerfile: ./web.Dockerfile
container_name: prisma
env_file:
- ./apps/web/.env
ports:
- '5555:5555'
working_dir: /app
volumes:
- ./apps/web/:/app
depends_on:
db:
condition: service_healthy
command: sh -c "bunx prisma generate && bunx prisma migrate dev && bunx prisma studio"

web:
build:
context: .
dockerfile: ./web.Dockerfile
container_name: web
platform: linux/amd64
working_dir: /app
stdin_open: true
tty: true
volumes:
- ./apps/web/:/app
- /app/node_modules
- /app/ui
- /app/eslint-config
- /app/tslint-config
ports:
- "3000:3000"
env_file:
- ./apps/web/.env
depends_on:
- prisma
command: sh -c "bun run dev"

storybook:
build:
context: .
dockerfile: ./web.Dockerfile
ports:
- "3000:3000"
env_file:
- ./apps/web/.env
depends_on:
- prisma
command: sh -c "bun run dev:storybook"

volumes:
mysql-data:

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"turbo": "^2.0.14",
"typescript": "^5.4.5"
},
"trustedDependencies": ["prisma", "esbuild"],
"engines": {
"node": ">=18"
},
Expand Down
35 changes: 35 additions & 0 deletions web.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Set Bun and Node version
ARG BUN_VERSION=1.1.13
ARG NODE_VERSION=20.12.2
FROM imbios/bun-node:${BUN_VERSION}-${NODE_VERSION}-slim AS base

WORKDIR /usr/src/app

FROM base AS install
RUN mkdir -p /temp/dev
WORKDIR /temp/dev
COPY ./apps/web/package.json ./apps/web/bun.lockb ./
COPY ./packages/eslint-config/ ./node_modules/@repo/eslint-config/
COPY ./packages/typescript-config/ ./node_modules/@repo/typescript-config/
COPY ./packages/ui/ ./node_modules/@repo/ui/
COPY ./apps/web/prisma/ ./prisma/
# TODO: Remove the || true to use trustedDependencies so bun
# can install the dependencies without error
# RUN bun install
# RUN bun install --frozen-lockfile || true
# RUN bun pm trust --all

# FROM base AS prerelease
# COPY --from=install /temp/dev/node_modules node_modules
# COPY --from=install /temp/dev/prisma prisma
# COPY . .

# FROM base AS release
# COPY --from=install /temp/dev/node_modules node_modules
# COPY --from=prerelease /usr/src/app/index.ts .
# COPY --from=prerelease /usr/src/app/package.json .

# COPY ./apps/web/ .


# CMD ["bun", "run", "dev"]