Skip to content

Commit 5e81388

Browse files
authored
Web: Abandon CRA, use Vite for building web app and provide new glue for plugins (#741)
1 parent 44c5789 commit 5e81388

File tree

155 files changed

+5890
-29041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+5890
-29041
lines changed

deploy/docker/Dockerfile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1+
FROM python:3.8-alpine AS build
2+
3+
WORKDIR /app
4+
RUN python3 -m venv /app/venv
5+
RUN /app/venv/bin/pip --no-cache-dir install wheel
6+
7+
RUN apk add --no-cache libffi libffi-dev py3-cffi build-base python3-dev automake m4 autoconf libtool gcc g++ musl-dev openssl-dev cargo postgresql-dev
8+
9+
COPY requirements.txt /app
10+
RUN /app/venv/bin/pip --no-cache-dir install -r /app/requirements.txt
11+
12+
COPY docker/plugins /app/plugins
13+
ARG plugins
14+
RUN for plugin in $plugins $(find /app/plugins -name 'setup.py' -exec dirname {} \; | sort -u); \
15+
do /app/venv/bin/pip --no-cache-dir install $plugin; done
16+
117
FROM python:3.8-alpine
218

319
LABEL maintainer="info@cert.pl"
420

521
RUN apk add --no-cache postgresql-client postgresql-dev libmagic
622

7-
COPY requirements.txt docker/plugins/requirements-*.txt /tmp/
8-
RUN apk add --no-cache -t build libffi libffi-dev py3-cffi build-base python3-dev automake m4 autoconf libtool gcc g++ musl-dev openssl-dev cargo \
9-
&& pip --no-cache-dir install -r /tmp/requirements.txt \
10-
&& ls /tmp/requirements-*.txt | xargs -i,, pip --no-cache-dir install -r ,, \
11-
&& apk del build
12-
1323
# Copy backend files
24+
COPY --from=build /app/venv /app/venv
1425
COPY docker/ setup.py MANIFEST.in requirements.txt /app/
1526
COPY mwdb /app/mwdb/
1627

1728
# Install mwdb-core package
18-
RUN pip install /app
29+
RUN /app/venv/bin/pip install /app
1930

2031
# Create a /app/uploads directory
2132
# Give +r to everything in /app and +x for directories
@@ -28,7 +39,6 @@ RUN mkdir -p /app/uploads/ && \
2839

2940
ENV PYTHONPATH=/app
3041
ENV FLASK_APP=/app/mwdb/app.py
31-
# How many workers gunicorn should spawn by default
3242
WORKDIR /app
3343

3444
CMD ["/app/start.sh"]

deploy/docker/Dockerfile-web

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
FROM node:14 AS build
1+
FROM node:16-alpine AS build
2+
3+
LABEL maintainer="info@cert.pl"
24

35
COPY ./mwdb/web /app
4-
COPY ./docker/plugins /plugins
6+
COPY ./docker/plugins /app/plugins
57

8+
ARG web_plugins
69
RUN cd /app \
7-
&& npm install --unsafe-perm . $(find /plugins -name 'package.json' -printf "%h\n" | sort -u) \
10+
&& npm install --unsafe-perm . $web_plugins $(find /app/plugins -name 'package.json' -exec dirname {} \; | sort -u) \
811
&& CI=true npm run build \
912
&& npm cache clean --force
1013

1114
FROM nginx:stable
1215

16+
LABEL maintainer="info@cert.pl"
17+
1318
ENV PROXY_BACKEND_URL http://mwdb.:8080
1419

1520
COPY docker/nginx.conf.template /etc/nginx/conf.d/default.conf.template
1621
COPY docker/start-web.sh /start-web.sh
17-
COPY --from=build /app/build /usr/share/nginx/html
22+
COPY --from=build /app/dist /usr/share/nginx/html
1823

1924
# Give +r to everything in /usr/share/nginx/html and +x for directories
2025
RUN chmod u=rX,go= -R /usr/share/nginx/html

deploy/docker/Dockerfile-web-dev

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
FROM node:14 AS build
1+
FROM node:16-alpine AS build
2+
3+
LABEL maintainer="info@cert.pl"
24

35
COPY ./mwdb/web /app
4-
COPY ./docker/plugins /plugins
6+
COPY ./docker/plugins /app/plugins
57

8+
ARG web_plugins
69
RUN cd /app \
7-
&& npm install --unsafe-perm . $(find /plugins -name 'package.json' -printf "%h\n" | sort -u) \
10+
&& npm install --unsafe-perm . $web_plugins $(find /app/plugins -name 'package.json' -exec dirname {} \; | sort -u) \
811
&& CI=true npm run build \
912
&& npm cache clean --force
1013

1114
ENV PROXY_BACKEND_URL http://mwdb.:8080
1215

1316
WORKDIR /app
14-
CMD ["npm", "run", "start"]
17+
CMD ["npm", "run", "dev"]

docker-compose-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ services:
5757
volumes:
5858
- "./mwdb/web/public:/app/public"
5959
- "./mwdb/web/src:/app/src"
60+
- "./docker/plugins:/app/plugins"
6061
restart: on-failure
6162
postgres:
6263
image: postgres

docker/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ until psql "$MWDB_POSTGRES_URI" -c "\q" ; do
77
done
88

99
echo "Configuring mwdb-core instance"
10-
mwdb-core configure --quiet basic && exec gunicorn
10+
/app/venv/bin/mwdb-core configure --quiet basic && exec /app/venv/bin/gunicorn

mwdb/web/config-overrides.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

mwdb/web/public/index.html renamed to mwdb/web/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
66
<meta name="theme-color" content="#000000">
7-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
8-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
97
<title>CERT.PL&gt;_ Malware Database</title>
108
</head>
119
<body>
1210
<noscript>
1311
You need to enable JavaScript to run this app.
1412
</noscript>
1513
<div id="root"></div>
14+
<script type="module" src="/src/index.jsx"></script>
1615
</body>
1716
</html>

0 commit comments

Comments
 (0)