create docker container from app

This commit is contained in:
Torben Haack 2024-10-09 12:41:58 +02:00
parent 709da8cc9a
commit 6aef6db4e4
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# Ignore node_modules as they will be installed in the container
node_modules
# Ignore build artifacts
.next
# Ignore runtime data
db/
# Ignore local configuration files
.env
.env.example
# Ignore version control files
.git
.gitignore
# Ignore IDE/editor specific files
*.log
*.tmp
*.DS_Store
.vscode/
.idea/

View File

@ -0,0 +1,37 @@
FROM node:20-bookworm
# Create application directory
RUN mkdir -p /usr/src/app
# Set environment variables
ENV PORT 3000
ENV NEXT_TELEMETRY_DISABLED=1
ENV RUNTIME_ENVIRONMENT=development
ENV OAUTH_CLIENT_ID=client_id
ENV OAUTH_CLIENT_SECRET=client_secret
WORKDIR /usr/src/app
# Copy package.json and pnpm-lock.yaml
COPY package.json /usr/src/app
COPY pnpm-lock.yaml /usr/src/app
# Install pnpm
RUN corepack enable pnpm
# Install dependencies
RUN pnpm install
# Copy the rest of the application code
COPY . /usr/src/app
# Initialize Database
RUN pnpm run db
# Build the application
RUN pnpm run build
EXPOSE 3000
# Start the application
CMD ["pnpm", "start"]

View File

@ -0,0 +1,13 @@
services:
app:
build:
context: .
dockerfile: Containerfile
ports:
- "3000:3000"
environment:
NODE_ENV: development
OAUTH_CLIENT_ID: 521f431132202fd5225d
OAUTH_CLIENT_SECRET: 12084446d467ad4bce75ace54d881a8287321d32
#volumes:
# - ./docker-test/db:/usr/src/app/db