Skip to content

Commit

Permalink
Web: Abandon CRA, use Vite for building web app and provide new glue …
Browse files Browse the repository at this point in the history
…for plugins (#741)
  • Loading branch information
psrok1 authored Jan 23, 2023
1 parent 44c5789 commit 5e81388
Show file tree
Hide file tree
Showing 155 changed files with 5,890 additions and 29,041 deletions.
26 changes: 18 additions & 8 deletions deploy/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
FROM python:3.8-alpine AS build

WORKDIR /app
RUN python3 -m venv /app/venv
RUN /app/venv/bin/pip --no-cache-dir install wheel

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

COPY requirements.txt /app
RUN /app/venv/bin/pip --no-cache-dir install -r /app/requirements.txt

COPY docker/plugins /app/plugins
ARG plugins
RUN for plugin in $plugins $(find /app/plugins -name 'setup.py' -exec dirname {} \; | sort -u); \
do /app/venv/bin/pip --no-cache-dir install $plugin; done

FROM python:3.8-alpine

LABEL maintainer="[email protected]"

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

COPY requirements.txt docker/plugins/requirements-*.txt /tmp/
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 \
&& pip --no-cache-dir install -r /tmp/requirements.txt \
&& ls /tmp/requirements-*.txt | xargs -i,, pip --no-cache-dir install -r ,, \
&& apk del build

# Copy backend files
COPY --from=build /app/venv /app/venv
COPY docker/ setup.py MANIFEST.in requirements.txt /app/
COPY mwdb /app/mwdb/

# Install mwdb-core package
RUN pip install /app
RUN /app/venv/bin/pip install /app

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

ENV PYTHONPATH=/app
ENV FLASK_APP=/app/mwdb/app.py
# How many workers gunicorn should spawn by default
WORKDIR /app

CMD ["/app/start.sh"]
13 changes: 9 additions & 4 deletions deploy/docker/Dockerfile-web
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
FROM node:14 AS build
FROM node:16-alpine AS build

LABEL maintainer="[email protected]"

COPY ./mwdb/web /app
COPY ./docker/plugins /plugins
COPY ./docker/plugins /app/plugins

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

FROM nginx:stable

LABEL maintainer="[email protected]"

ENV PROXY_BACKEND_URL http://mwdb.:8080

COPY docker/nginx.conf.template /etc/nginx/conf.d/default.conf.template
COPY docker/start-web.sh /start-web.sh
COPY --from=build /app/build /usr/share/nginx/html
COPY --from=build /app/dist /usr/share/nginx/html

# Give +r to everything in /usr/share/nginx/html and +x for directories
RUN chmod u=rX,go= -R /usr/share/nginx/html
Expand Down
11 changes: 7 additions & 4 deletions deploy/docker/Dockerfile-web-dev
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM node:14 AS build
FROM node:16-alpine AS build

LABEL maintainer="[email protected]"

COPY ./mwdb/web /app
COPY ./docker/plugins /plugins
COPY ./docker/plugins /app/plugins

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

ENV PROXY_BACKEND_URL http://mwdb.:8080

WORKDIR /app
CMD ["npm", "run", "start"]
CMD ["npm", "run", "dev"]
1 change: 1 addition & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ services:
volumes:
- "./mwdb/web/public:/app/public"
- "./mwdb/web/src:/app/src"
- "./docker/plugins:/app/plugins"
restart: on-failure
postgres:
image: postgres
Expand Down
2 changes: 1 addition & 1 deletion docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ until psql "$MWDB_POSTGRES_URI" -c "\q" ; do
done

echo "Configuring mwdb-core instance"
mwdb-core configure --quiet basic && exec gunicorn
/app/venv/bin/mwdb-core configure --quiet basic && exec /app/venv/bin/gunicorn
81 changes: 0 additions & 81 deletions mwdb/web/config-overrides.js

This file was deleted.

3 changes: 1 addition & 2 deletions mwdb/web/public/index.html → mwdb/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<title>CERT.PL&gt;_ Malware Database</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>
Loading

0 comments on commit 5e81388

Please sign in to comment.