Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Build Optimization and Space Management #2

Open
C2100-PR opened this issue Dec 4, 2024 · 0 comments
Open

Docker Build Optimization and Space Management #2

C2100-PR opened this issue Dec 4, 2024 · 0 comments

Comments

@C2100-PR
Copy link
Owner

C2100-PR commented Dec 4, 2024

Docker Build Optimization

1. Cleanup Commands

# Remove all unused containers, networks, images and volumes
docker system prune --volumes -f

# Remove all unused images
docker system prune -a -f

2. .dockerignore Configuration

Create a .dockerignore file with:

# Node
node_modules
npm-debug.log
yarn-debug.log
yarn-error.log

# Development
.git
.gitignore
.env
.env.local
.env.*.local
*.md
.vscode
.idea

# Testing
coverage
.nyc_output
test

# Build
dist
build
.next
out

# Misc
.DS_Store
*.log

3. Optimized Dockerfile

# Use slim base image
FROM node:18-slim

# Set working directory
WORKDIR /app

# Copy only package files first
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy only necessary files
COPY src/ ./src/
COPY public/ ./public/

# Set environment
ENV PORT=8080
EXPOSE 8080

# Start the app
CMD ["node", "src/server.js"]

4. Build Command with Optimization

# Build with optimized options
docker build --no-cache --compress -t disc-assessment .

Steps to Implement:

  1. Run cleanup commands
  2. Add .dockerignore file
  3. Update Dockerfile
  4. Rebuild with optimized settings

Please implement these changes to resolve the disk space issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant