fix: review compose dev for clean startup
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# Declare MONGODB_URI as an argument for the builder stage
|
||||
ARG MONGODB_URI
|
||||
ENV MONGODB_URI=$MONGODB_URI
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
@@ -14,8 +18,8 @@ RUN corepack enable
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
# Copy configuration files
|
||||
COPY tsconfig.json next-env.d.ts .eslintrc.json ./
|
||||
COPY tailwind.config.ts postcss.config.js .env ./
|
||||
COPY tsconfig.json .eslintrc.json ./
|
||||
COPY tailwind.config.ts postcss.config.js ./
|
||||
|
||||
# Install dependencies with Yarn
|
||||
RUN yarn install --frozen-lockfile
|
||||
@@ -43,7 +47,6 @@ COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/next-env.d.ts ./
|
||||
COPY --from=builder /app/tailwind.config.ts ./
|
||||
COPY --from=builder /app/.env ./
|
||||
|
||||
# Add non-root user for security
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
|
||||
@@ -5,6 +5,8 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- MONGODB_URI=${MONGODB_URI}
|
||||
container_name: stripstream-app
|
||||
ports:
|
||||
- "3000:3000"
|
||||
@@ -14,6 +16,9 @@ services:
|
||||
- /app/.next
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- MONGO_USER=admin
|
||||
- MONGO_PASSWORD=password123
|
||||
- MONGODB_URI=mongodb://admin:password123@mongodb:27017/stripstream?authSource=admin
|
||||
command: npm run dev
|
||||
|
||||
mongodb:
|
||||
@@ -21,12 +26,14 @@ services:
|
||||
container_name: stripstream_mongodb
|
||||
restart: always
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER}
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
|
||||
MONGO_INITDB_ROOT_USERNAME: admin
|
||||
MONGO_INITDB_ROOT_PASSWORD: password123
|
||||
MONGO_INITDB_DATABASE: stripstream
|
||||
ports:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- mongodb_data:/data/db
|
||||
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||
|
||||
volumes:
|
||||
mongodb_data:
|
||||
|
||||
23
mongo-init.js
Normal file
23
mongo-init.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// MongoDB initialization script
|
||||
db = db.getSiblingDB('stripstream');
|
||||
|
||||
// Create a user for the stripstream database
|
||||
db.createUser({
|
||||
user: 'admin',
|
||||
pwd: 'password123',
|
||||
roles: [
|
||||
{
|
||||
role: 'readWrite',
|
||||
db: 'stripstream'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// Create initial collections
|
||||
db.createCollection('users');
|
||||
db.createCollection('configs');
|
||||
db.createCollection('preferences');
|
||||
db.createCollection('favorites');
|
||||
db.createCollection('bookProgress');
|
||||
|
||||
print('MongoDB initialization completed successfully');
|
||||
@@ -39,7 +39,7 @@
|
||||
"zod": "3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "20.11.16",
|
||||
"@types/node": "24.7.0",
|
||||
"@types/react": "18.2.64",
|
||||
"@types/react-dom": "18.2.21",
|
||||
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
||||
|
||||
20
yarn.lock
20
yarn.lock
@@ -981,12 +981,12 @@
|
||||
dependencies:
|
||||
undici-types "~6.20.0"
|
||||
|
||||
"@types/node@20.11.16":
|
||||
version "20.11.16"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz"
|
||||
integrity sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==
|
||||
"@types/node@24.7.0":
|
||||
version "24.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-24.7.0.tgz#a34c9f0d3401db396782e440317dd5d8373c286f"
|
||||
integrity sha512-IbKooQVqUBrlzWTi79E8Fw78l8k1RNtlDDNWsFZs7XonuQSJ8oNYfEeclhprUldXISRMLzBpILuKgPlIxm+/Yw==
|
||||
dependencies:
|
||||
undici-types "~5.26.4"
|
||||
undici-types "~7.14.0"
|
||||
|
||||
"@types/prop-types@*":
|
||||
version "15.7.14"
|
||||
@@ -4473,16 +4473,16 @@ unbox-primitive@^1.1.0:
|
||||
has-symbols "^1.1.0"
|
||||
which-boxed-primitive "^1.1.1"
|
||||
|
||||
undici-types@~5.26.4:
|
||||
version "5.26.5"
|
||||
resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz"
|
||||
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
||||
|
||||
undici-types@~6.20.0:
|
||||
version "6.20.0"
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433"
|
||||
integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==
|
||||
|
||||
undici-types@~7.14.0:
|
||||
version "7.14.0"
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.14.0.tgz#4c037b32ca4d7d62fae042174604341588bc0840"
|
||||
integrity sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==
|
||||
|
||||
update-browserslist-db@^1.1.1:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.2.tgz"
|
||||
|
||||
Reference in New Issue
Block a user