Skip to content

Commit

Permalink
Merge pull request #13 from SkidGod4444/bugfix/docker
Browse files Browse the repository at this point in the history
try to fix docker
  • Loading branch information
SkidGod4444 authored Nov 6, 2024
2 parents 41f7490 + 0225acc commit 8c47947
Show file tree
Hide file tree
Showing 23 changed files with 610 additions and 11,969 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
node_modules
npm-debug.log
pnpm-debug.log
.git
.gitignore
*.md
dist
39 changes: 0 additions & 39 deletions .github/workflows/dependancy-update.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
pull_request:
branches:
- main
- 'feature/*'
- 'bugfix/*'

jobs:
lint:
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/test-multiple-node-versions.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: CI
name: Run Test on Multiple Node Versions

on:
push:
branches:
- 'tpn/*'
pull_request:
branches:
- 'tpn/*'
push:
branches:
- main
- 'feature/*'
- 'bugfix/*'
pull_request:
branches:
- main
- 'feature/*'
- 'bugfix/*'

jobs:
test:
Expand Down
25 changes: 0 additions & 25 deletions Dockerfile

This file was deleted.

7 changes: 4 additions & 3 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# prod
out/

# dev
.vercel/
.next/
.yarn/
!.yarn/releases
.vscode/*
Expand Down Expand Up @@ -27,5 +30,3 @@ lerna-debug.log*

# misc
.DS_Store

.vercel
41 changes: 41 additions & 0 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM namesmt/images-alpine:node-aws-dev_pnpm10.0.0-alpha.0 AS base

RUN pnpm install -g turbo
WORKDIR /usr/home/plura/api
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --no-frozen-lockfile

FROM base AS builder

WORKDIR /usr/home/plura/api
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --no-frozen-lockfile
COPY . .
ENV TURBO_REMOTE_CACHE=false
RUN turbo prune api --docker

FROM base AS installer

WORKDIR /usr/home/plura/api

COPY --from=builder /usr/home/plura/api/out/json/ .
RUN pnpm install --no-frozen-lockfile
COPY --from=builder /usr/home/plura/api/out/full/ .
RUN pnpm run build
RUN turbo build --filter=api...

FROM base AS runner

# RUN addgroup --system --gid 4444 honojs
# RUN adduser --system --uid 4444 skidgod

WORKDIR /usr/home/plura/api
RUN pnpm install --no-frozen-lockfile
# RUN chown -R skidgod:honojs /root/.local/share/pnpm

# USER skidgod

COPY --from=installer /usr/home/plura/api .

# Start the application
CMD ["pnpm", "start"]
2 changes: 1 addition & 1 deletion apps/api/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```
npm install
npm run start
npm run dev
```
14 changes: 0 additions & 14 deletions apps/api/api/index.ts

This file was deleted.

14 changes: 14 additions & 0 deletions apps/api/app/api/[...route]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Hono } from 'hono'
import { handle } from 'hono/vercel'

export const runtime = 'edge'

const app = new Hono().basePath('/api')

app.get('/hello', (c) => {
return c.json({
message: 'Hello from Hono!'
})
})

export const GET = handle(app)
18 changes: 18 additions & 0 deletions apps/api/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: 'Hono | nextjs',
description: 'Generated by hono'
}

export default function RootLayout({
children
}: Readonly<{
children: React.ReactNode
}>) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
19 changes: 19 additions & 0 deletions apps/api/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use client'
import { useEffect, useState } from 'react'

export default function Home() {
const [message, setMessage] = useState()

useEffect(() => {
const fetchData = async () => {
const res = await fetch('/api/hello')
const { message } = await res.json()
setMessage(message)
}
fetchData()
}, [])

if (!message) return <p>Loading...</p>

return <p>{message}</p>
}
5 changes: 5 additions & 0 deletions apps/api/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
6 changes: 6 additions & 0 deletions apps/api/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}

module.exports = nextConfig
18 changes: 12 additions & 6 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"name": "api",
"scripts": {
"start": "vercel dev",
"deploy": "vercel --prod",
"test": "vitest"
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"hono": "^4.6.9"
"hono": "^4.6.9",
"next": "14.2.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"vercel": "^32.4.1",
"vitest": "^2.1.4"
"@types/node": "18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"typescript": "^5"
}
}
Binary file removed apps/api/public/favicon.ico
Binary file not shown.
40 changes: 36 additions & 4 deletions apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"target": "es2022",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@/*": [
"./*"
]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
8 changes: 0 additions & 8 deletions apps/api/vercel.json

This file was deleted.

40 changes: 35 additions & 5 deletions apps/www/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
FROM node:20.12.0-alpine3.19
FROM namesmt/images-alpine:node-aws-dev_pnpm10.0.0-alpha.0 AS base

RUN pnpm install -g turbo
WORKDIR /usr/home/plura
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --no-frozen-lockfile

COPY package.json package-lock.json turbo.json tsconfig.json ./
FROM base AS builder

RUN pnpm install
WORKDIR /usr/home/plura
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --no-frozen-lockfile
COPY . .
ENV TURBO_REMOTE_CACHE=false
RUN turbo prune www --docker

FROM base AS installer

WORKDIR /usr/home/plura

COPY --from=builder /usr/home/plura/out/json/ .
RUN pnpm install --no-frozen-lockfile
COPY --from=builder /usr/home/plura/out/full/ .
RUN pnpm run build
RUN turbo build --filter=www...

FROM base AS runner

# Don't run production as root
# RUN addgroup --system --gid 4444 nextjs
# RUN adduser --system --uid 4444 skidgod

WORKDIR /usr/home/plura

RUN pnpm install --no-frozen-lockfile
# RUN chown -R skidgod:nextjs /root/.local/share/pnpm

# USER skidgod

EXPOSE 3001
COPY --from=installer /usr/home/plura .

CMD ["pnpm", "start"]
# Run the application
CMD ["pnpm", "start"]
Loading

0 comments on commit 8c47947

Please sign in to comment.