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 #8

Merged
merged 8 commits into from
Nov 25, 2022
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/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Docker Image CI

concurrency:
group: docker-image-ci
cancel-in-progress: true

on:
push:
# branches:
# - master
workflow_run:
workflows: [ "Docker Base Image CI" ]
types:
- completed

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64,amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64
push: true
tags: josecols/metapy:0.2.13
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ doc/
*.o
*.class
.*
!.github/
data/ceeaus
data/breast-cancer
data/housing
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "deps/meta"]
path = deps/meta
url = https://github.com/meta-toolkit/meta.git
url = https://github.com/dmcguire81/meta
[submodule "deps/pybind11"]
path = deps/pybind11
url = https://github.com/pybind/pybind11
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM josecols/meta:3.0.2 as base

ARG TARGETARCH
COPY . /metapy

RUN apt-get update && apt-get install -y \
python-is-python3 \
python3-dev \
python3-pip

WORKDIR /metapy
RUN git submodule update --init --recursive -- deps/pybind11
RUN mkdir build
RUN sed -i 's:add_subdirectory(deps/meta EXCLUDE_FROM_ALL):find_package(MeTA 3.0.2 REQUIRED):g' CMakeLists.txt
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this just builds the pybind11 code and not the dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, MeTA and its dependencies are already built as libraries.

RUN pip install .

FROM base AS branch-arm64
ENV LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libjemalloc.so.2

FROM base AS branch-amd64
ENV LD_PRELOAD=/lib/x86_64-linux-gnu/libjemalloc.so.2

FROM branch-${TARGETARCH} AS final

WORKDIR /app
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ to make it seamless to use MeTA's components within any Python application
This project is made possible by the excellent [pybind11][pybind11]
library.

## Getting Started (Docker)

A [Docker](https://www.docker.com/) image with a pre-built version of MeTA and `metapy` is available on [Docker Hub](https://hub.docker.com/r/josecols/metapy/tags)

```bash
docker pull josecols/metapy:0.2.13
```

This Docker image simplifies the execution of Python scripts that rely on `metapy`. For example, to run CS 410 Text Information Systems MP assignments, simply run the following command at the MP directory's root.

```bash
docker run -it --rm --name metapy --mount type=bind,source=$(pwd),target=/app --entrypoint bash josecols/metapy:0.2.13
```

Then, you can run the Python scripts as usual, e.g., `python mp1.py`. Keep in mind that any changes to files in your current directory that occur within the container will be automatically reflected on your host file system.

## Getting Started (the easy way)

```bash
Expand Down