-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (66 loc) · 2.88 KB
/
Dockerfile
File metadata and controls
75 lines (66 loc) · 2.88 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
FROM ubuntu:22.04
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# This software is licensed to you under the terms of the Cisco Sample
# Code License, Version 1.1 (the "License"). You may obtain a copy of the
# License at
#
# https://developer.cisco.com/docs/licenses
#
# All use of the material herein must be in accordance with the terms of
# the License. All rights not expressly granted by the License are
# reserved. Unless required by applicable law or agreed to separately in
# writing, software distributed under the License is distributed on an "AS
# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied.
#
LABEL version="1.0"
LABEL description="Firehasher: Feed URL MD5 Hasher"
LABEL maintainer="nciesins@cisco.com"
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get upgrade \
&& apt-get install --no-install-recommends -y \
python3 \
pip \
nginx \
redis \
&& apt-get clean \
&& apt-get purge \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
COPY app.py .
COPY config.yaml .
RUN pip install --no-cache-dir -r requirements.txt && \
mkdir data && \
touch init.sh && \
chmod 744 init.sh && \
echo "#!/bin/sh" >> init.sh && \
echo "NGINX_CONF='/etc/nginx/sites-available/xdrmd5.conf'" >> init.sh && \
echo "echo \"server {\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" listen 80;\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" location / {\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" proxy_pass http://127.0.0.1:8000;\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" proxy_set_header Host \\\$host;\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" proxy_set_header X-Real-IP \\\$remote_addr;\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" proxy_set_header X-Forwarded-For \\\$proxy_add_x_forwarded_for;\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" proxy_set_header X-Forwarded-Proto \\\$scheme;\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \" }\" >> \$NGINX_CONF" >> init.sh && \
echo "echo \"}\" >> \$NGINX_CONF" >> init.sh && \
echo "rm /etc/nginx/sites-enabled/default" >> init.sh && \
echo "ln -s /etc/nginx/sites-available/xdrmd5.conf /etc/nginx/sites-enabled/xdrmd5.conf" >> init.sh && \
echo "ln -sf /dev/stdout /var/log/nginx/access.log" >> init.sh && \
echo "ln -sf /dev/stderr /var/log/nginx/error.log" >> init.sh && \
touch run.sh && \
chmod 744 run.sh && \
echo "#!/bin/sh" >> run.sh && \
echo "./init.sh" >> run.sh && \
echo "sed -i '/.\/init.sh/{N;d;}' ./run.sh" >> run.sh && \
echo "nginx -g 'daemon off;' &" >> run.sh && \
echo "redis-server &" >> run.sh && \
echo "gunicorn --preload --workers=4 --bind 0.0.0.0:8000 app:app" >> run.sh
EXPOSE 80
CMD ["./run.sh"]