-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
70 lines (52 loc) · 1.94 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
FROM python:3.11-slim as build
# COPY custom-root-ca.crt /usr/local/share/ca-certificates
# RUN update-ca-certificates
ARG NWRFC_ZIP
ARG SAPCAR_EXE
ARG CRYPTOLIB_SAR
# Setup OS stuff
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get upgrade -y && apt-get install -y python3-dev uuid uuid-runtime gcc g++ unzip
# Copy SAP tools
#COPY nwrfc750P_12-70002752.zip .
COPY ${NWRFC_ZIP} .
#COPY SAPCAR .
COPY ${SAPCAR_EXE} .
#COPY SAPCRYPTOLIBP_8551-20011697.SAR .
COPY ${CRYPTOLIB_SAR} .
RUN chmod u+x ${SAPCAR_EXE}
# Prepare RFC library
RUN mkdir -p /usr/local && cd /usr/local && unzip /${NWRFC_ZIP}
RUN mkdir /sec && cd sec && /${SAPCAR_EXE} -xf /${CRYPTOLIB_SAR}
ENV SAPNWRFC_HOME /usr/local/nwrfcsdk
ENV LD_LIBRARY_PATH=/usr/local/nwrfcsdk/lib:${LD_LIBRARY_PATH}
# Install python libraries
RUN python -m venv /opt/venv
# Enable venv
ENV PATH="/opt/venv/bin:$PATH"
# RUN pip install --cert=/usr/local/share/custom-root-ca.crt install truststore
# RUN pip config set global.use-feature truststore
RUN pip install pyrfc
# Setup SNC PSE
ENV SECUDIR /sec
RUN --mount=type=secret,id=key,required=true,dst=/run/secrets/key.p12 --mount=type=secret,id=pass,required=true \
cd /sec && \
./sapgenpse import_p12 -x $(cat /run/secrets/pass) -z $(cat /run/secrets/pass) -p rfc.pse /run/secrets/key.p12
FROM python:3.11-slim as run
COPY --from=build /usr/local/nwrfcsdk /usr/local/nwrfcsdk
COPY --from=build /sec /sec
COPY --from=build /opt/venv /opt/venv
RUN useradd -u 2000 pyrfc && \
chown -R pyrfc /sec
USER pyrfc
ENV PATH="/opt/venv/bin:$PATH"
ENV SAPNWRFC_HOME /usr/local/nwrfcsdk
ENV LD_LIBRARY_PATH=/usr/local/nwrfcsdk/lib:${LD_LIBRARY_PATH}
ENV SECUDIR /sec
RUN --mount=type=secret,uid=2000,id=pass,required=true \
cd $SECUDIR && \
./sapgenpse seclogin -x $(cat /run/secrets/pass) -p rfc.pse && \
chmod 400 ${SECUDIR}/rfc.pse
ENTRYPOINT [ "python" ]
CMD "pyrfc-test.py"