-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
124 lines (95 loc) · 3.67 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
FROM python:3.12.2 AS build
LABEL developer="Miloslavskiy Sergey"
LABEL maintainer="MiloslavskiySergey@yandex.ru"
# Installing required build packages
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
cmake \
build-essential \
libboost-all-dev \
python3-dev \
unzip && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Set timezone
ENV TZ="Europe/Moscow"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone
# Copy files to install CryptoPro
COPY ./dist /cprocsp
# Choosing a working directory for installing CryptoPro
WORKDIR /cprocsp
# Download the archive from CryptoPro CSP (https://cryptopro.ru/products/csp/downloads#latest_csp50r2_linux), unpack this
# archive and install CryptoPro CSP
RUN set -ex && \
tar xvf linux-amd64_deb.tgz && \
./linux-amd64_deb/install.sh && \
# Install cprocsp-devel package
apt-get install ./linux-amd64_deb/lsb-cprocsp-devel_*.deb
# Download the archive from the CruptoPro EDS SDK (https://cryptopro.ru/products/cades/downloads), unpack this archive
# and install the cprocsp-pki-cades package (version 2.0.14071 or later)
RUN set -ex && \
mkdir ./cades-linux-amd64 && \
tar xvf cades-linux-amd64.tar.gz && \
apt-get install ./cades-linux-amd64/cprocsp-pki-cades-*amd64.deb
# Download and extract the pycades source archive
# (https://cryptopro.ru/sites/default/files/products/cades/pycades/pycades.zip)
RUN set -ex && \
unzip pycades.zip && \
# Set the value of the Python_INCLUDE_DIR variable in the CMakeList.txt file (Python.h folder)
sed -i '2c\SET(Python_INCLUDE_DIR "/usr/local/include/python3.12")' ./pycades_*/CMakeLists.txt
# ENV PYCADES="pycades_0.1.30636"
# Build extension pucades
RUN set -ex && \
#cd /cprocsp/$PYCADES && \
cd /cprocsp/pycades_* && \
mkdir build && \
cd build && \
cmake .. && \
make -j4
FROM python:3.12.2
# Adding a new layer
# ENV PYCADES="pycades_0.1.30636"
# Copying CryptoPro and expanding pycades from the previous stage
COPY --from=build /cprocsp/pycades_*/pycades.so /usr/local/lib/python3.10/pycades.so
COPY --from=build /opt/cprocsp /opt/cprocsp/
COPY --from=build /var/opt/cprocsp /var/opt/cprocsp/
COPY --from=build /etc/opt/cprocsp /etc/opt/cprocsp/
# Installing the package for container operation via command line
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends expect && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Copying bash scripts for container operation via command
ADD scripts /scripts
ADD certificates /certificates
# Creation of symbolic links in the contaioner so that CryptoPro functions can be performed via the command line
RUN cd /bin && \
ln -s /opt/cprocsp/bin/amd64/certmgr && \
ln -s /opt/cprocsp/bin/amd64/cpverify && \
ln -s /opt/cprocsp/bin/amd64/cryptcp && \
ln -s /opt/cprocsp/bin/amd64/csptest && \
ln -s /opt/cprocsp/bin/amd64/csptestf && \
ln -s /opt/cprocsp/bin/amd64/der2xer && \
ln -s /opt/cprocsp/bin/amd64/inittst && \
ln -s /opt/cprocsp/bin/amd64/wipefile && \
ln -s /opt/cprocsp/sbin/amd64/cpconfig
#FROM cryptopro-AppFastApi
ENV PYTHONUNBUFFERED 1
ENV PATH /usr/local/bin:$PATH
ENV LANG C.UTF-8
RUN mkdir /AppFastApi && \
mkdir /AppFastApi/static
WORKDIR /AppFastApi
RUN apt-get update -y && \
pip install poetry && \
pip install --upgrade pip
# apt-get autoremove -y && \
# rm -rf /var/lib/apt/lists/*
COPY /AppFastApi /AppFastApi
RUN poetry install
#CMD poetry run uvicorn main:app --host 0.0.0.0 --port 80
#CMD ['poetry', 'run', 'uvicorn', 'main:app', '--reload', '--host', 'localhost', '--port', '80']