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

Docker image creation #94

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
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
48 changes: 48 additions & 0 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build drunc docker image

on:
push:
branches:
- develop
tags:
- 'v*'
paths:
- Dockerfile

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout drunc code
uses: actions/checkout@v4
with:
repository: DUNE-DAQ/drunc
path: drunc

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/DUNE-DAQ/drunc
tags: |
type=raw,value=latest
type=ref,event=branch
type=ref,event=tag

- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: ${{ github.workspace }}/drunc/
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
73 changes: 43 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,61 @@ FROM python:3.10.4-bullseye
SHELL ["/bin/bash", "-c"]

# Update the packages list and install the required packages
RUN apt update && apt install -y --no-install-recommends \
RUN apt-get update

RUN apt-get install -y --no-install-recommends \
git \
openssh-server \
openssh-client
openssh-client \
net-tools \
sudo

RUN cd /etc/ssh/ && ssh-keygen -A

RUN echo 'root:r00t' | chpasswd

# Update the SSHD configuration to allow root login without password
RUN printf "\nPermitRootLogin without-password\n" >> /etc/ssh/sshd_config && \
printf "Port 23\n" >> /etc/ssh/sshd_config

RUN printf " Port 23\n" >> /etc/ssh/ssh_config && \
printf " StrictHostKeyChecking no\n" >> /etc/ssh/ssh_config && \
printf " PasswordAuthentication no\n" >> /etc/ssh/ssh_config && \
printf " UserKnownHostsFile /dev/null\n" >> /etc/ssh/ssh_config && \
printf " AddressFamily inet" >> /etc/ssh/ssh_config

RUN mkdir /run/sshd

RUN adduser --shell /bin/bash --ingroup sudo patreides
RUN echo 'patreides:chani' | chpasswd
RUN usermod -aG sudo patreides

RUN service ssh start

# Expose SSH port (which was changed from 22 to 23 a couple of lines above)
EXPOSE 23
EXPOSE 10054

USER patreides

WORKDIR /home/patreides

# Clone the repository and install the required Python packages
RUN cd / && \
RUN cd /home/patreides && \
git clone -b develop https://github.com/DUNE-DAQ/druncschema.git && \
cd druncschema && \
pip install -r requirements.txt && \
pip install .

RUN cd / && \
RUN cd /home/patreides && \
git clone -b develop https://github.com/DUNE-DAQ/drunc.git && \
cd drunc && \
pip install -r requirements.txt && \
pip install .

# # Start a new build stage with Python 3.10.4-bullseye as the base image
# FROM python:3.10.4-bullseye

# # Copy everything from the builder stage
# COPY --from=builder / /

# Generate root ssh key
RUN mkdir -p /root/.ssh && \
ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" && \
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys

# Update the SSHD configuration to allow root login without password
RUN echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config && \
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
echo "UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config

# # Define environment variables
# ENV DRUNC_DIR=/drunc
# ENV DRUNC_DATA=/drunc/data

# Expose SSH default port
EXPOSE 22
EXPOSE 10054
RUN mkdir /home/patreides/.ssh
RUN ssh-keygen -f /home/patreides/.ssh/id_rsa -q -N ""
RUN cp /home/patreides/.ssh/id_rsa.pub /home/patreides/.ssh/authorized_keys

# Run SSHD in the background and drunc-process-manager in the foreground
ENTRYPOINT service ssh start && drunc-process-manager --loglevel debug /drunc/data/process-manager-pocket.json
# Run SSHD in the background
#ENTRYPOINT echo 'chani' | sudo -S service ssh start

66 changes: 0 additions & 66 deletions Dockerfile_standalone

This file was deleted.