Skip to content

Commit d7898f2

Browse files
committed
Updates after testing local Docker image build
1 parent b22dfac commit d7898f2

File tree

4 files changed

+99
-18
lines changed

4 files changed

+99
-18
lines changed

.github/workflows/main.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Docker Image Generation
2+
3+
on:
4+
# Triggers the workflow on push or pull request events for specific branches
5+
push:
6+
branches: [ dockerize ]
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19+
- uses: actions/checkout@v3
20+
# Fetch all history for all tags and branches
21+
with:
22+
fetch-depth: 0
23+
24+
- name: checkout rfsoc-streamer
25+
uses: actions/checkout@v3
26+
with:
27+
repository: ccatobs/rfsoc-streamer
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
# Set up Docker Buildx
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v2
39+
40+
# Add Docker layer caching
41+
- name: Cache Docker layers
42+
uses: actions/cache@v3
43+
with:
44+
path: /tmp/.buildx-cache
45+
key: ${{ runner.os }}-buildx-${{ github.sha }}
46+
restore-keys: |
47+
${{ runner.os }}-buildx-
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: docker/metadata-action@v4
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
54+
- name: Build and push Docker image
55+
uses: docker/build-push-action@v4
56+
with:
57+
context: .
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
builder: ${{ steps.buildx.outputs.name }}
62+
cache-from: type=local,src=/tmp/.buildx-cache
63+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
64+
65+
# Temp fix for cache size growth
66+
- name: Move cache
67+
run: |
68+
rm -rf /tmp/.buildx-cache
69+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
70+

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ include_directories(${SPT3G_DIR}/core/src)
5858
include_directories(${SO3G_DIR}/include)
5959
include_directories(/usr/include/python3.10)
6060
include_directories(${PROJECT_SOURCE_DIR}/include/) # rfsoc-streamer/include
61-
include_directories(/usr/local/lib/python3.10/dist-packages/numpy/core/include/)
61+
include_directories(/opt/venv/lib/python3.10/site-packages/numpy/core/include)
6262

6363
# Create rfsoc python library
6464
set(SRC_FILES ${PROJECT_SOURCE_DIR}/src/RfsocBuilder.cxx ${PROJECT_SOURCE_DIR}/src/RfsocTransmitter.cxx ${PROJECT_SOURCE_DIR}/src/python.cpp)

Dockerfile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,33 @@ RUN apt-get update && apt-get install -y gcc \
1010
# Workaround for build issue with so3g needing specifically the 'python' executable
1111
RUN ln -s /usr/bin/python3.10 /usr/bin/python
1212

13+
# Create streamer user and group
14+
RUN groupadd -g 9003 streamer && \
15+
useradd -m -l -u 9003 -g 9003 streamer
16+
17+
# Setting up virtual environment
18+
RUN python3 -m venv /opt/venv/
19+
ENV PATH="/opt/venv/bin:$PATH"
20+
RUN python3 -m pip install -U pip
21+
1322
# Guaranteeing that there will be a common build directory for socs/spt3g
1423
WORKDIR /usr/local/so3g
1524
WORKDIR /usr/local/src
1625

17-
ENV SO3G_DIR /usr/local/src/so3g
18-
ENV SPT3G_DIR /usr/local/src/spt3g_software
19-
ENV SPT3G_SOFTWARE_PATH /usr/local/src/spt3g_software
20-
ENV RFSOC_DIR /usr/local/src/rfsoc-streamer
21-
ENV LD_LIBRARY_PATH /usr/local/so3g/lib:/usr/local/so3g/so3g
22-
ENV STREAM_CONFIG_DIR /config
23-
ENV SPT3G_SOFTWARE_BUILD_PATH ${SPT3G_DIR}/build
24-
ENV SO3G_BUILD_PATH /usr/local/so3g/lib
26+
ENV SO3G_DIR=/usr/local/src/so3g
27+
ENV SPT3G_DIR=/usr/local/src/spt3g_software
28+
ENV SPT3G_SOFTWARE_PATH=/usr/local/src/spt3g_software
29+
ENV RFSOC_DIR=/usr/local/src/rfsoc-streamer
30+
ENV LD_LIBRARY_PATH=/usr/local/so3g/lib:/usr/local/so3g/so3g
31+
ENV STREAM_CONFIG_DIR=/config
32+
ENV SPT3G_SOFTWARE_BUILD_PATH=${SPT3G_DIR}/build
33+
ENV SO3G_BUILD_PATH=/usr/local/so3g/lib
2534

2635
# Clone all repos
2736
RUN git clone https://github.com/CMB-S4/spt3g_software.git
2837
RUN git clone https://github.com/simonsobs/so3g.git
29-
RUN git clone https://github.com/ccatobs/rfsoc-streamer.git
38+
#RUN git clone https://github.com/ccatobs/rfsoc-streamer.git
39+
COPY . /usr/local/src/rfsoc-streamer
3040

3141
# Install spt3g
3242
WORKDIR /usr/local/src/spt3g_software/build
@@ -47,7 +57,7 @@ RUN make install
4757

4858
# Install so3g
4959
WORKDIR /usr/local/src/so3g
50-
RUN pip3 install -r requirements.txt
60+
RUN pip install -r requirements.txt
5161
WORKDIR /usr/local/src/so3g/build
5262

5363
# Seems to have a bug with finding cmake here...hash -r fixes it
@@ -65,13 +75,14 @@ RUN make install
6575

6676
# Install rfsoc-streamer
6777
WORKDIR /usr/local/src/rfsoc-streamer
68-
RUN CMAKE .
69-
RUN MAKE
78+
RUN cmake .
79+
RUN make
7080

71-
export PYTHONPATH="${RFSOC_DIR}/lib:${RFSOC_DIR}/python:$SPT3G_SOFTWARE_BUILD_PATH:$SO3G_BUILD_PATH:$PYTHONPATH"
72-
export PATH="/usr/local/so3g/bin:${PATH}"
81+
# There is no PYTHONPATH to start, so no need to append it to the end here
82+
ENV PYTHONPATH="${RFSOC_DIR}/lib:${RFSOC_DIR}/python:$SPT3G_SOFTWARE_BUILD_PATH:$SO3G_BUILD_PATH"
83+
ENV PATH="/usr/local/so3g/bin:${PATH}"
7384

74-
RUN pip3 install dumb-init
85+
RUN pip install dumb-init
7586

7687
# The command to run stream.py will be in the docker-compose.yml file
7788
# for more granular user control

test/stream_config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
g3_dir: /home/streamer/data/g3/ # path to top level detector file directory
2-
file_rotation_time: 600 #60*10 # time before rotating files in seconds
1+
g3_dir: /data/g3/ # path to top level detector file directory
2+
file_rotation_time: 60 #60*10 # time before rotating files in seconds
33

44
# Board and drone specific settings for all active RFSoCs
55
# stream IDs must have format rfsoc##_drone# - this is parsed to use in filenames

0 commit comments

Comments
 (0)