Skip to content

Commit

Permalink
Add build and runtime containers
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Mar 7, 2024
1 parent 9309486 commit 30b532d
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.dockerignore
docker/
98 changes: 98 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Container CI

on:
push:
# Build for main, tags and PRs
# Builds from PRs are not pushed to the registry because of rules in the steps
branches:
- docker
tags:
- "*"
pull_request:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # All history

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta config build
id: meta-build
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}-build
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Docker build build image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
target: build
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-build.outputs.tags }}
labels: ${{ steps.meta-build.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Docker meta config runtime
id: meta-runtime
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}-runtime
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Docker build runtime image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
target: runtime
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-runtime.outputs.tags }}
labels: ${{ steps.meta-runtime.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
48 changes: 48 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM fedora:37 AS build

RUN dnf update -y && dnf install -y \
# General build
gcc-c++ make cmake git \
# odin-data C++ dependencies
blosc-devel boost-devel hdf5-devel log4cxx-devel libpcap-devel zeromq-devel \
# python
python3-devel python3-pip && \
# tidy up
dnf -y clean all

# Root of odin-data
COPY . /tmp/odin-data

# C++
WORKDIR /tmp/odin-data
ENV PATH=/odin/bin:$PATH
RUN mkdir /odin && \
mkdir -p build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/odin ../cpp && \
make -j8 VERBOSE=1 && \
make install

# Python
WORKDIR /tmp/odin-data/python
ENV PATH=/odin/venv/bin:$PATH
RUN python3 -m venv /odin/venv && \
python -m pip install --upgrade pip && \
python -m pip install git+https://github.com/odin-detector/odin-control@1.3.0 && \
python -m pip install .[meta_writer]

RUN rm -rf /tmp/odin-data

# Runtime Image
FROM fedora:37 as runtime

RUN dnf update -y && dnf install -y \
# odin-data C++ runtime dependencies
blosc boost hdf5 log4cxx libpcap zeromq && \
# tidy up
dnf -y clean all

COPY --from=build /odin /odin

ENV PATH=/odin/bin:/odin/venv/bin:$PATH

WORKDIR /odin

0 comments on commit 30b532d

Please sign in to comment.