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 04bad39
Show file tree
Hide file tree
Showing 7 changed files with 27 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
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 NEXT_PUBLIC_FIREBASE_CONFIG
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 client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('dotenv').config({ path: '../server/.env' });
module.exports = {
reactStrictMode: true,
pageExtensions: ['page.tsx'],
trailingSlash: true,
env: {
API_BASE_PATH: process.env.API_BASE_PATH,
FIREBASE_AUTH_EMULATOR_HOST: process.env.FIREBASE_AUTH_EMULATOR_HOST,
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.

2 changes: 1 addition & 1 deletion server/service/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const init = (serverFactory?: FastifyServerFactory): FastifyInstance => {

fastify.register(helmet);
fastify.register(cookie);
fastify.register(fastifyStatic, { root: join(__dirname, '../out') });
fastify.register(fastifyStatic, { root: join(process.cwd(), '../client/out') });
server(fastify, { basePath: API_BASE_PATH });

return fastify;
Expand Down

0 comments on commit 04bad39

Please sign in to comment.