-
-
Notifications
You must be signed in to change notification settings - Fork 0
Copilot/sub pr 16 #27
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
Changes from all commits
f906614
c9c11a4
a6c783c
e04b0f1
c4623aa
dee0828
0656738
5034aab
d6c2507
5bdce78
02fdc80
fec255d
a60d662
8180653
b7fbcf9
eeeb013
f5a64ae
9213d90
2df0839
f94db3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # Virtual environments | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # Git | ||
| .git | ||
| .gitignore | ||
| .gitattributes | ||
|
|
||
| # Environment variables (will be mounted) | ||
| .env | ||
| config.json | ||
|
|
||
| # Database | ||
| *.db | ||
| *.sqlite | ||
| *.sqlite3 | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # Documentation | ||
| *.md | ||
| !README.md | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| .coverage | ||
| htmlcov/ | ||
| tests/ | ||
|
|
||
| # Temporary files | ||
| /tmp/ | ||
| *.tmp | ||
|
|
||
| # CI/CD | ||
| .github/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: Docker Build and Push | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| push: | ||
| branches: [ main ] | ||
| tags: [ 'v*' ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| jobs: | ||
| docker: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v4 | ||
| with: | ||
| images: elmourabea/megabot | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| - name: Build and push | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Publish to PyPI | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build twine | ||
|
|
||
| - name: Build package | ||
| run: python -m build | ||
|
|
||
| - name: Check distribution | ||
| run: twine check dist/* | ||
|
|
||
| - name: Publish to PyPI | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
| run: twine upload dist/* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # MEGA-Bot Dockerfile | ||
| # Multi-stage build for optimized production image | ||
|
|
||
| FROM python:3.11-slim as builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install build dependencies | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| gcc \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy requirements and install dependencies | ||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir --user -r requirements.txt | ||
|
|
||
| # Copy application code | ||
| COPY . . | ||
|
|
||
| # Install the package | ||
| RUN pip install --no-cache-dir --user -e . | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For production Docker images, it's better to use a standard package installation ( |
||
|
|
||
| # Production stage | ||
| FROM python:3.11-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy installed packages from builder | ||
| COPY --from=builder /root/.local /root/.local | ||
| COPY --from=builder /app /app | ||
|
|
||
| # Make sure scripts in .local are usable | ||
| ENV PATH=/root/.local/bin:$PATH | ||
|
|
||
| # Create directory for database | ||
| RUN mkdir -p /data | ||
|
ELMOURABEA marked this conversation as resolved.
|
||
|
|
||
| # Expose API port | ||
| EXPOSE 5000 | ||
|
|
||
| # Set environment variables | ||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV DATABASE_PATH=/data/megabot.db | ||
|
|
||
| # Default command: run API server | ||
| CMD ["megabot-server", "--port", "5000"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring the
tests/directory is good for keeping the final production image lean. However, you might also want to consider ignoring theexamples/directory for the same reason, unless you have a specific need for them to be present in the Docker image.