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

Dockerize my app #72

Merged
merged 29 commits into from
Nov 18, 2024

Conversation

Johnnyevans32
Copy link
Contributor

Dockerization Toolkit (Dockerize-My-App) for Goose

Resolves #64

Overview

The Dockerization Toolkit automates the creation of Docker-related configuration files for software projects. It detects the project type and generates essential Docker configuration files such as Dockerfile, .dockerignore, and optionally docker-compose.yml for multi-container setups.


Features

  • Automatic Project Detection:
    • Python: Detects requirements.txt or pyproject.toml.
    • Node.js: Detects package.json.
    • Java: Detects pom.xml or build.gradle.
  • Generated Files:
    • Dockerfile: Optimized configuration for each project type.
    • .dockerignore: Excludes unnecessary files from the Docker build context.
    • docker-compose.yml (optional): Configures multi-container orchestration.

Usage

  1. Add the toolkit to your profiles.yaml:
my_profile:
  provider: openai
  processor: gpt-4o
  accelerator: gpt-4o-mini
  moderator: passive
  toolkits:
    - dockerize_my_app
  1. Run Goose with the profile:
goose session start --profile my-profile
  1. Use the toolkit:
dockerize my app  <path_to_project> into <output_directory>

Output

The toolkit generates the following files in the specified output directory:

Dockerfile

For Python Projects:

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "app.py"]

For Node.js Projects:

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]

For Java Projects:

FROM openjdk:17-jdk-slim
WORKDIR /app
COPY . .
RUN ./gradlew build
CMD ["java", "-jar", "build/libs/app.jar"]

.dockerignore

.git/
.env
node_modules/
__pycache__/
*.pyc
target/

docker-compose.yml (if applicable):

version: "3.8"
services:
  app:
    build:
      context: .
    ports:
      - "8080:8080"

Testing

Run tests using pytest:

uv run pytest tests -m "not integration"

🛠️ Adding to goose-plugins

pyproject.toml

[project.entry-points."goose.toolkit"]
dockerize_my_app = "goose.toolkit.dockerize_my_app:DockerizationToolkit"

Copy link
Collaborator

@blackgirlbytes blackgirlbytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 will review during the week

Copy link
Collaborator

@blackgirlbytes blackgirlbytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh i think you accidentally pulled in changes from your previous PR

@Johnnyevans32
Copy link
Contributor Author

fixed now

@blackgirlbytes
Copy link
Collaborator

@Johnnyevans32 Since I merged your first toolkit, it created conflicts. resolve conflicts please!

.gitignore Outdated
@@ -27,6 +27,9 @@ share/python-wheels/
*.egg
MANIFEST


.DS_Store
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm should we remove this since it wasnt in the original gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed now @blackgirlbytes

pyproject.toml Outdated Show resolved Hide resolved
@blackgirlbytes
Copy link
Collaborator

@Johnnyevans32 looks like your pipeline is failing due to linting errors. Try running the commands below to fix your linting issues:

uvx ruff format src/goose_plugins/toolkits/complexity_analyzer.py
ruff check --fix src/goose_plugins/toolkits/complexity_analyzer.py

@Johnnyevans32
Copy link
Contributor Author

fixed now @blackgirlbytes

Copy link
Collaborator

@blackgirlbytes blackgirlbytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good! Thanks for the contribution!

@blackgirlbytes blackgirlbytes merged commit 01cb4e2 into block-open-source:main Nov 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Your Own Toolkit for Goose! 🛠️
2 participants