Skip to content
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
25 changes: 25 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,28 @@ jobs:

- name: Run tox
run: tox -e py

docker-build:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.10"

- name: Install the project
run: uv sync --all-extras --dev

- name: Install tox
run: uv tool install tox --with tox-uv

- name: Build Docker image
run: uv run tox -e docker-build
49 changes: 35 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,30 @@
# specific language governing permissions and limitations
# under the License.

FROM python:3.8-slim-bookworm
# Builder stage - build the wheel
FROM ghcr.io/astral-sh/uv:debian AS builder

# Install build dependencies
RUN apt-get update --assume-yes && \
apt-get install -o 'Dpkg::Options::=--force-confnew' -y --force-yes -q \
gcc \
clang \
build-essential \
make \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /build

# Copy source code
COPY . /build

# Build the wheel using uv
RUN uv build --wheel

# Runtime stage - install and run the package
FROM python:3.10-slim-bookworm AS runtime

# So that STDOUT/STDERR is printed
ENV PYTHONUNBUFFERED="1"
ARG UV_VERSION=0.8.3
Expand All @@ -29,24 +52,22 @@ RUN groupadd --gid 8192 otava && \
useradd --uid 8192 --shell /bin/false --create-home --no-log-init --gid otava otava && \
chown otava:otava ${OTAVA_HOME}

# First let's just get things updated.
# Install System dependencies

# Install build dependencies needed for native extensions
RUN apt-get update --assume-yes && \
apt-get install -o 'Dpkg::Options::=--force-confnew' -y --force-yes -q \
git \
openssh-client \
gcc \
clang \
build-essential \
make \
&& rm -rf /var/lib/apt/lists/*

# Copy the rest of the program over
COPY --chown=otava:otava . ${OTAVA_HOME}
# Copy the wheel from builder stage
COPY --from=builder /build/dist/*.whl /tmp/

# Install the wheel using uv
RUN pip install /tmp/apache_otava-*.whl && rm /tmp/apache_otava-*.whl

ENV PATH="${OTAVA_HOME}/bin:$PATH"
# Switch to otava user
USER otava

RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv --mount=type=ssh \
uv pip install --system -e ".[dev]" && \
mkdir -p bin && \
ln -s ../venv/bin/otava ${OTAVA_HOME}/bin
# The otava command should now be available in PATH via the installed package
ENTRYPOINT ["otava"]
2 changes: 1 addition & 1 deletion docs/CSV.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tests:
## Example

```bash
docker-compose -f examples/csv/docker-compose.yaml run --build otava bin/otava analyze local.sample
docker-compose -f examples/csv/docker-compose.yaml run --build otava analyze local.sample
```

Expected output:
Expand Down
3 changes: 2 additions & 1 deletion examples/csv/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
dockerfile: Dockerfile
container_name: otava
environment:
OTAVA_CONFIG: examples/csv/otava.yaml
OTAVA_CONFIG: /config/otava.yaml
volumes:
- ./data:/data
- ./config:/config
27 changes: 0 additions & 27 deletions examples/csv/otava.yaml

This file was deleted.

11 changes: 4 additions & 7 deletions examples/graphite/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
ports:
- "3000:3000"
volumes:
- ./grafana:/etc/grafana/provisioning
- ./grafana:/etc/grafana/provisioning
networks:
- otava-graphite

Expand All @@ -65,15 +65,12 @@ services:
GRAFANA_ADDRESS: http://grafana:3000/
GRAFANA_USER: admin
GRAFANA_PASSWORD: admin
OTAVA_CONFIG: examples/graphite/otava.yaml
OTAVA_CONFIG: /config/otava.yaml
networks:
- otava-graphite
volumes:
- ./config:/config

networks:
otava-graphite:
driver: bridge


# TODO:
# 3. make sure Otava can connect to graphite and query the data
# 4. make sure it annotates the dashboard correctly
48 changes: 0 additions & 48 deletions examples/graphite/otava.yaml

This file was deleted.

7 changes: 3 additions & 4 deletions examples/postgresql/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

version: "3.8"

services:
postgres:
image: postgres:latest
Expand Down Expand Up @@ -45,10 +42,12 @@ services:
POSTGRES_USERNAME: exampleuser
POSTGRES_PASSWORD: examplepassword
POSTGRES_DATABASE: benchmark_results
OTAVA_CONFIG: examples/postgresql/otava.yaml
OTAVA_CONFIG: /config/otava.yaml
BRANCH: trunk
networks:
- otava-postgres
volumes:
- ./config:/config

networks:
otava-postgres:
Expand Down
94 changes: 0 additions & 94 deletions examples/postgresql/otava.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ setenv =
DOCKER_PROJECT=apache/otava
UV_OPTS = -v
commands =
docker buildx build --tag {env:DOCKER_PROJECT}:latest --ssh=default .
docker buildx build --tag {env:DOCKER_PROJECT}:latest .
push: docker image tag {env:DOCKER_PROJECT}:latest {env:DOCKER_PROJECT}:{env:RELEASE_VERSION}
push: docker image tag {env:DOCKER_PROJECT}:{env:RELEASE_VERSION} {env:DOCKER_REGISTRY}/{env:DOCKER_PROJECT}:{env:RELEASE_VERSION}
push: docker image tag {env:DOCKER_PROJECT}:latest {env:DOCKER_REGISTRY}/{env:DOCKER_PROJECT}:latest
Expand Down