Skip to content

Commit

Permalink
chore: add Dockerfile for deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jun 4, 2024
1 parent ef00799 commit ae5e39c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
with:
path: 'server/node_modules'
key: server-npm-${{ hashFiles('server/package-lock.json') }}
- run: npm install
- run: npm ci
if: steps.root-npm-cache.outputs.cache-hit != 'true'
- run: npm install --prefix client
- run: npm ci --prefix client
if: steps.client-npm-cache.outputs.cache-hit != 'true'
- run: npm install --prefix server
- run: npm ci --prefix server
if: steps.server-npm-cache.outputs.cache-hit != 'true'
- run: npm run generate
- run: npm run lint
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY package.json package-lock.json .
RUN npm ci

COPY client/package.json client/package-lock.json ./client/
RUN npm ci --prefix client

COPY server/package.json server/package-lock.json ./server/
RUN npm ci --prefix server

COPY . .
ARG DATABASE_URL
RUN npm run build

CMD npm start
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Next frourio starter

フロントエンドは client ディレクトリの [Next.js](https://nextjs.org/) 、バックエンドは server ディレクトリの [frourio](https://frourio.com/) で構築された TypeScript で一気通貫開発が可能なモノレポサービス
フロントエンドは client ディレクトリの [Next.js](https://nextjs.org) 、バックエンドは server ディレクトリの [frourio](https://frourio.com) で構築された TypeScript で一気通貫開発が可能なモノレポサービス

最新のコミットによるデモ - https://solufa.github.io/next-frourio-starter/
最新のコミットによるデモ - https://starter.frourio.com

## 開発手順

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint": "run-p lint:*",
"lint:client": "npm run lint:fix --prefix client",
"lint:server": "npm run lint:fix --prefix server",
"start": "npm start --prefix server",
"test": "run-p test:*",
"test:client": "npm run test --prefix client",
"test:server": "npm run test --prefix server",
Expand Down
1 change: 0 additions & 1 deletion server/out

This file was deleted.

7 changes: 6 additions & 1 deletion server/service/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import helmet from '@fastify/helmet';
import fastifyStatic from '@fastify/static';
import type { FastifyInstance, FastifyServerFactory } from 'fastify';
import Fastify from 'fastify';
import { existsSync, readdirSync } from 'fs';
import { join } from 'path';
import { API_BASE_PATH } from 'service/envValues';

Expand All @@ -12,7 +13,11 @@ export const init = (serverFactory?: FastifyServerFactory): FastifyInstance => {

fastify.register(helmet);
fastify.register(cookie);
fastify.register(fastifyStatic, { root: join(__dirname, '../out') });
fastify.register(fastifyStatic, { root: join(__dirname, '../client/out') });
console.log(
333,
existsSync(join(__dirname, '../client/out')) && readdirSync(join(__dirname, '../client/out')),
);
server(fastify, { basePath: API_BASE_PATH });

return fastify;
Expand Down

0 comments on commit ae5e39c

Please sign in to comment.