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

Add Docker support #7

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Push Docker image

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

env:
REGISTRY: docker.io
IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/package-name

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
if: github.event_name == 'push' # Only log in on pushes to main
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name == 'push' }} # Only push on pushes to main
tags: ${{ env.IMAGE_NAME }}:latest
labels: ${{ env.IMAGE_NAME }}:latest
platforms: linux/amd64,linux/arm64
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ====================
# Build Neurobro Agent
# ====================

FROM python:3.12-slim
WORKDIR /src

ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONFAULTHANDLER=1

# -----------------------
# Install system packages
# -----------------------

RUN apt-get update && apt-get install -y
curl \
&& rm -rf /var/lib/apt/lists/*


RUN pip install pipenv

# -------------------------
# Create the logs directory
# -------------------------

RUN mkdir logs

# ---------------------
# Setup the environment
# ---------------------

COPY Pipfile .
COPY Pipfile.lock .

RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy

# ----------------------
# Runtime
# ----------------------

COPY . /src

COPY entrypoint.sh /src/entrypoint.sh

RUN chmod +x /src/entrypoint.sh

# Command to run the application
ENTRYPOINT ["/src/entrypoint.sh"]
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/bash

set -x
set -euo pipefail

# Run the main application
echo "Starting the main application..."
exec pipenv run python -m src.main
Loading