Skip to content

Commit 80716ee

Browse files
committed
first attempt to dockerize server and job preparation
1 parent 7a96c06 commit 80716ee

File tree

6 files changed

+109
-6
lines changed

6 files changed

+109
-6
lines changed

client/job_preparation/Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Using Python original Docker image
2+
FROM --platform=linux/amd64 python:3.9-alpine
3+
4+
# Install necessary packages
5+
RUN apk add \
6+
curl \
7+
build-base \
8+
libffi-dev
9+
10+
RUN curl https://sh.rustup.rs -sSf -o rustup.sh ; chmod +x rustup.sh ; ./rustup.sh -y
11+
ENV PATH="$PATH:/root/.cargo/bin"
12+
13+
# Create code directory, output directory
14+
RUN mkdir /job_preparation
15+
16+
# Copy useful data from the project
17+
COPY ./client/job_preparation /job_preparation
18+
19+
# Copy utils for SPIFFEID creation ...
20+
COPY ./utils /job_preparation/utils
21+
22+
# Install dependencies
23+
RUN cd /job_preparation && pip install -r ./requirements.txt
24+
25+
# Set workdir
26+
WORKDIR /job_preparation
27+
28+
# Set entrypoint
29+
ENTRYPOINT [ "python3", "./prepare_job.py" ]
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cryptography==42.0.5
2+
pyOpenSSL==24.0.0
3+
protobuf==3.20.0
4+
pyyaml==5.3.1
5+
pyrage==1.1.2
6+
paramiko==3.4.0
7+
scp==0.14.5
8+
pre-commit

server/Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Using Python original Docker image
2+
FROM --platform=linux/amd64 python:3.9-alpine
3+
4+
RUN apk add \
5+
git \
6+
build-base \
7+
openssl
8+
9+
# Install spire-agent
10+
RUN wget -q https://github.com/spiffe/spire/releases/download/v1.9.0/spire-1.9.0-linux-amd64-musl.tar.gz
11+
RUN tar xvf spire-1.9.0-linux-amd64-musl.tar.gz ; mv spire-1.9.0 /opt ; mv /opt/spire-1.9.0 /opt/spire
12+
RUN ln -s /opt/spire/bin/spire-agent /usr/bin/spire-agent
13+
14+
# Install pyspiffe package
15+
RUN pip install git+https://github.com/HewlettPackard/py-spiffe.git
16+
17+
# Copy server
18+
RUN mkdir /server
19+
COPY ./server /server
20+
21+
# Install dependencies
22+
RUN cd /server && pip install -r ./requirements.txt
23+
24+
# Copy utils
25+
COPY ./utils /server/utils
26+
27+
# Set workdir
28+
WORKDIR /server
29+
30+
# Set entrypoint
31+
ENTRYPOINT [ "./entrypoint.sh" ]

server/entrypoint.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
#
3+
## This entrypoint wraps the HPCS server with a spire agent
4+
#
5+
6+
# export PYTHONPATH="${PYTHONPATH}:/server:/utils"
7+
8+
# Cleanup spire-agent generated files
9+
end_entrypoint() {
10+
echo "Cleaning everything before leaving ..."
11+
rm -rf /tmp/data
12+
rm -r /tmp/spire-agent
13+
kill "$1"
14+
exit "$2"
15+
}
16+
17+
# Reset spire data everytime
18+
rm -rf /tmp/data
19+
20+
# Spawn spire agent with mounted configuration
21+
spire-agent run -config /tmp/agent.conf || end_entrypoint 0 1 &
22+
spire_agent_pid=$!
23+
24+
agent_socket_path=$(cat /tmp/agent.conf | grep "socket_path" | cut -d "=" -f2 | cut -d "\"" -f1)
25+
26+
sleep 10
27+
until [ -e $agent_socket_path ]
28+
do
29+
echo -e "${RED}[LUMI-SD][Data preparation] Spire workload api socket doesn't exist, waiting 10 seconds ${NC}"
30+
sleep 10
31+
done
32+
33+
python3 ./app.py || end_entrypoint $spire_agent_pid 1
34+
35+
end_entrypoint $spire_agent_pid 0

server/lib/spire_interactions.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
pre_command = "microk8s.kubectl exec -n spire spire-server-0 --"
99

1010

11-
jwt_workload_api = default_jwt_source.DefaultJwtSource(
12-
spiffe_socket_path="unix:///tmp/spire-agent/public/api.sock"
11+
jwt_workload_api = default_jwt_source.DefaultJwtSource(
12+
workload_api_client=None,
13+
spiffe_socket_path="unix:///tmp/spire-agent/public/api.sock",
14+
timeout_in_seconds=None
1315
)
1416

1517

server/requirements.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
cryptography==2.8
2-
dockerfile_parse==2.0.1
3-
pyOpenSSL==19.0.0
4-
docker==7.0.0
1+
cryptography==42.0.5
2+
pyOpenSSL==24.0.0
53
protobuf==3.20.0
64
hvac==2.1.0
75
quart==0.19.4

0 commit comments

Comments
 (0)