Add docker-compose.yaml

This commit is contained in:
Takeshi Kimata
2024-06-16 19:35:04 +09:00
parent a8cd231a82
commit d4db61860f
6 changed files with 36 additions and 20 deletions

7
backend/.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.git
database.sqlite

View File

@@ -5,12 +5,7 @@ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
COPY . . COPY . .
ENV FRONTEND_ORIGIN=http://localhost:8000
ENV PORT=8001
EXPOSE $PORT EXPOSE $PORT
RUN npx sequelize db:migrate RUN npx sequelize db:migrate
RUN echo "Migration complete."
CMD ["node", "index.js"] CMD ["node", "index.js"]

View File

@@ -1,14 +1,14 @@
{ {
"development": { "development": {
"dialect": "sqlite", "dialect": "sqlite",
"storage": "database.sqlite" "storage": "database/database.sqlite"
}, },
"test": { "test": {
"dialect": "sqlite", "dialect": "sqlite",
"storage": "database.test.sqlite" "storage": "database/database.sqlite"
}, },
"production": { "production": {
"dialect": "sqlite", "dialect": "sqlite",
"storage": "database.production.sqlite" "storage": "database/database.sqlite"
} }
} }

View File

@@ -21,7 +21,7 @@ app.use(express.static(path.join(__dirname, 'public')));
// init sequalize // init sequalize
const sequelize = new Sequelize({ const sequelize = new Sequelize({
dialect: 'sqlite', dialect: 'sqlite',
storage: 'database.sqlite', storage: 'database/database.sqlite',
}); });
// "/" // "/"

View File

@@ -1,14 +1,31 @@
version: '3' version: '3.8'
services: services:
frontend:
build:
context: ./frontend
ports:
- '8000:8000'
depends_on:
- backend
backend: backend:
image: unittcms-backend:latest
build: build:
context: ./backend context: ./backend
ports: ports:
- '8001:8001' - '8001:8001'
environment:
- NODE_ENV=production
- FRONTEND_ORIGIN=http://localhost:8000
- PORT=8001
volumes:
- db-data:/app/database
frontend:
image: unittcms-frontend:latest
build:
context: ./frontend
ports:
- '8000:8000'
environment:
- NODE_ENV=production
- NEXT_PUBLIC_BACKEND_ORIGIN=http://localhost:8001
- PORT=8000
depends_on:
- backend
volumes:
db-data:

View File

@@ -38,7 +38,6 @@ RUN \
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime. # Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1 # ENV NEXT_TELEMETRY_DISABLED 1
@@ -60,8 +59,6 @@ USER nextjs
EXPOSE 8000 EXPOSE 8000
ENV PORT 8000
# server.js is created by next build from the standalone output # server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output # https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js CMD HOSTNAME="0.0.0.0" node server.js