-
Notifications
You must be signed in to change notification settings - Fork 458
Expand file tree
/
Copy pathDockerfile
More file actions
147 lines (115 loc) · 4.42 KB
/
Dockerfile
File metadata and controls
147 lines (115 loc) · 4.42 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
###############################################################################
#----------------------------- BUILD STAGE ------------------------------#
###############################################################################
FROM python:3.10.16-slim-bullseye as builder
ARG CC_REPO=https://github.com/Ericsson/CodeChecker.git
ENV CC_REPO ${CC_REPO}
ARG CC_VERSION=master
ENV CC_VERSION ${CC_VERSION}
COPY hooks/ /hooks
ARG DEBIAN_FRONTEND=noninteractive
RUN set -x && apt-get update -qq \
&& apt-get install -qqy --no-install-recommends \
ca-certificates \
curl \
git \
make \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs
# Download CodeChecker release.
RUN git clone ${CC_REPO} /codechecker
WORKDIR /codechecker
RUN git checkout ${CC_VERSION}
# Run script before the package generation.
RUN chmod a+x /hooks/before_build.sh && sync && /hooks/before_build.sh
# Build CodeChecker web.
RUN make -C /codechecker/web package
# Run script after the package generation is finished.
RUN chmod a+x /hooks/after_build.sh && sync && /hooks/after_build.sh
###############################################################################
#-------------------------- PRODUCTION STAGE ----------------------------#
###############################################################################
FROM python:3.10.16-slim-bullseye
ARG CC_GID=950
ARG CC_UID=950
ENV CC_GID ${CC_GID}
ENV CC_UID ${CC_UID}
ARG INSTALL_AUTH=yes
ARG INSTALL_PG8000=no
ARG INSTALL_PSYCOPG2=yes
ENV TINI_VERSION v0.18.0
ENV WAIT_FOR_VERSION v2.1.2
RUN set -x && apt-get update -qq \
# Prevent fail when install postgresql-client.
&& mkdir -p /usr/share/man/man1 \
&& mkdir -p /usr/share/man/man7 \
\
&& apt-get install -qqy --no-install-recommends ca-certificates \
postgresql-client \
# To switch user and exec command.
gosu
RUN if [ "$INSTALL_AUTH" = "yes" ] ; then \
apt-get install -qqy --no-install-recommends \
libldap-common \
libldap2-dev \
libsasl2-dev \
libssl-dev; \
fi
RUN if [ "$INSTALL_PSYCOPG2" = "yes" ] ; then \
apt-get install -qqy --no-install-recommends \
libpq-dev; \
fi
COPY --from=builder /codechecker/web/build/CodeChecker /codechecker
# Copy python requirements.
COPY --from=builder /codechecker/web/requirements_py /requirements_py
COPY --from=builder /codechecker/web/requirements.txt /requirements_py
# Copy local API packages (Python, Node).
COPY --from=builder /codechecker/web/api /api
# Install python requirements.
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
python3-dev \
# gcc is needed to build psutil.
gcc \
# netcat is needed for 'wait-for' script.
netcat \
\
# Install necessary runtime environment files.
&& pip3 install -r /requirements_py/requirements.txt \
&& if [ "$INSTALL_AUTH" = "yes" ] ; then \
pip3 install -r /requirements_py/auth/requirements.txt; \
fi \
&& if [ "$INSTALL_PG8000" = "yes" ] ; then \
pip3 install -r /requirements_py/db_pg8000/requirements.txt; \
fi \
&& if [ "$INSTALL_PSYCOPG2" = "yes" ] ; then \
pip3 install -r /requirements_py/db_psycopg2/requirements.txt; \
fi \
\
# Remove unnecessary packages.
&& pip3 uninstall -y wheel \
&& apt-get purge -y --auto-remove \
gcc \
python-dev \
\
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& set +x
# Create user and group for CodeChecker.
RUN groupadd -r codechecker -g ${CC_GID} \
&& useradd -r --no-log-init -M -u ${CC_UID} -g codechecker codechecker
# Change permission of the CodeChecker package.
RUN chown codechecker:codechecker /codechecker
ENV PATH="/codechecker/bin:$PATH"
COPY ./entrypoint.sh /usr/local/bin/
RUN chmod a+x /usr/local/bin/entrypoint.sh \
&& chown codechecker:codechecker /usr/local/bin/entrypoint.sh
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod 755 /tini
ADD https://raw.githubusercontent.com/eficode/wait-for/${WAIT_FOR_VERSION}/wait-for /usr/local/bin/wait-for
RUN chmod 755 /usr/local/bin/wait-for
EXPOSE 8001
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD python3 -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8001/live', timeout=3).read()" || exit 1
ENTRYPOINT ["/tini", "--", "/usr/local/bin/entrypoint.sh"]
CMD ["CodeChecker", "server", "--workspace", "/workspace", "--not-host-only"]