diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..b0e7f7d
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,12 @@
+.git
+**/node_modules
+**/build
+**/coverage
+venv
+*.pyc
+__pycache__
+*.egg-info
+config.ini
+config.development.ini
+web.log
+web.sock
diff --git a/Dockerfile-counter b/Dockerfile-counter
index cfecc32..76b6021 100644
--- a/Dockerfile-counter
+++ b/Dockerfile-counter
@@ -1,19 +1,12 @@
-FROM ubuntu:18.04
-
-RUN apt-get update
-RUN apt-get install -y python3-pip
-
-RUN pip3 install --upgrade pip
-
-ENV APP_DIR /deploy
-
-RUN mkdir -p ${APP_DIR}
-
-COPY . ${APP_DIR}
+FROM python:3.11-slim
+ENV APP_DIR=/deploy
WORKDIR ${APP_DIR}
-RUN pip3 install -r ${APP_DIR}/requirements.txt
+COPY requirements.txt ${APP_DIR}/requirements.txt
+RUN pip3 install --no-cache-dir --upgrade pip \
+ && pip3 install --no-cache-dir -r ${APP_DIR}/requirements.txt
-CMD ["python3", "counter/main.py"]
+COPY . ${APP_DIR}
+CMD ["python3", "counter/main.py"]
diff --git a/Dockerfile-web b/Dockerfile-web
index 43726bd..37ebc6b 100644
--- a/Dockerfile-web
+++ b/Dockerfile-web
@@ -1,31 +1,32 @@
-FROM node:8
+# --- Stage 1: build the React SPA ---
+FROM node:20-bookworm-slim AS web-build
-RUN apt-get update
-RUN apt-get install -y python3-pip
+WORKDIR /app/react_app
-RUN pip3 install --upgrade pip
+# Install dependencies against the committed lockfile first (better layer caching).
+# node:20 already ships yarn 1.22.x.
+COPY react_app/package.json react_app/yarn.lock ./
+RUN yarn install --frozen-lockfile --non-interactive
-ENV APP_DIR /deploy
+# Build the static bundle into /app/react_app/build
+COPY react_app/ ./
+RUN yarn build
-RUN mkdir -p ${APP_DIR}
-
-COPY . ${APP_DIR}
+# --- Stage 2: Python runtime (Flask + gunicorn) ---
+FROM python:3.11-slim
+ENV APP_DIR=/deploy
WORKDIR ${APP_DIR}
-RUN pip3 install -r ${APP_DIR}/requirements.txt
-
-WORKDIR ${APP_DIR}/react_app
-
-RUN npm rebuild node-sass
+COPY requirements.txt ${APP_DIR}/requirements.txt
+RUN pip3 install --no-cache-dir --upgrade pip \
+ && pip3 install --no-cache-dir -r ${APP_DIR}/requirements.txt
-RUN yarn
-
-RUN yarn run build
+COPY . ${APP_DIR}
-WORKDIR ${APP_DIR}
+# Bring in the built SPA from the build stage (app.py serves react_app/build)
+COPY --from=web-build /app/react_app/build ${APP_DIR}/react_app/build
EXPOSE 5001
-CMD ["gunicorn", "app:app", "-b", "0.0.0.0:5001"]
-
+CMD ["gunicorn", "app:app", "-b", "0.0.0.0:5001"]
diff --git a/app.py b/app.py
index 718d971..317b89f 100644
--- a/app.py
+++ b/app.py
@@ -8,7 +8,7 @@
from flask import request, jsonify, abort
from flask_cors import CORS
from werkzeug.middleware.proxy_fix import ProxyFix
-from xonfig import get_option
+from appconfig import get_option
REDIS_HOST = get_option('REDIS', 'HOST')
REDIS_PORT = get_option('REDIS', 'PORT')
diff --git a/appconfig.py b/appconfig.py
new file mode 100644
index 0000000..be36d66
--- /dev/null
+++ b/appconfig.py
@@ -0,0 +1,86 @@
+# Minimal stdlib-based config reader.
+#
+# Replaces the `xonfig` package, which is unmaintained and crashes on
+# Python 3.10+ (its custom interpolation no longer satisfies configparser's
+# isinstance check). Behaviour kept compatible with how app.py used xonfig:
+# - reads config.ini (then an env-specific overlay) from the working dir or a
+# parent directory,
+# - coerces values with ast.literal_eval so ints/floats/bools come back typed,
+# - supports __ENV__SECTION_OPTION environment variable overrides,
+# - keeps option keys case-sensitive.
+import ast
+import configparser
+import os
+
+
+def _literal_eval(val):
+ try:
+ return ast.literal_eval(val)
+ except (SyntaxError, ValueError):
+ return val
+
+
+class _Interpolation(configparser.Interpolation):
+ def before_get(self, parser, section, option, value, defaults):
+ return _literal_eval(value)
+
+
+_config = configparser.ConfigParser(interpolation=_Interpolation())
+_config.optionxform = str
+
+
+def _lookup_dirs():
+ cwd = os.path.abspath(os.getcwd())
+ return [
+ cwd,
+ os.path.abspath(os.path.join(cwd, '..')),
+ os.path.abspath(os.path.join(cwd, '..', '..')),
+ ]
+
+
+def _read_files():
+ env = (os.environ.get('__ENV__') or '').lower()
+ env_file = 'config.{}.ini'.format(env) if env in ('testing', 'production') else 'config.development.ini'
+
+ for name in ('config.ini', env_file):
+ for directory in _lookup_dirs():
+ path = os.path.join(directory, name)
+ if os.path.isfile(path):
+ _config.read(path)
+ break
+
+
+def _split_section_option(rest):
+ # Prefer the longest already-known section that prefixes the key, so a
+ # section name containing underscores (e.g. ESEARCH_API) is matched as a
+ # whole instead of being split at its first underscore. Falls back to the
+ # first underscore when no defined section matches.
+ for section in sorted(_config.sections(), key=len, reverse=True):
+ if rest == section:
+ return None
+ if rest.startswith(section + '_'):
+ return section, rest[len(section) + 1:]
+ if '_' in rest:
+ return tuple(rest.split('_', 1))
+ return None
+
+
+def _read_env():
+ for key, value in os.environ.items():
+ if not key.startswith('__ENV__') or len(key) == len('__ENV__'):
+ continue
+ parsed = _split_section_option(key[len('__ENV__'):])
+ if not parsed:
+ continue
+ section, option = parsed
+ if not _config.has_section(section):
+ _config.add_section(section)
+ _config.set(section, option, value)
+
+
+_read_files()
+_read_env()
+
+
+def get_option(section, option):
+ return _config.get(section, option)
diff --git a/counter/main.py b/counter/main.py
index 4c77bc3..257a2c3 100644
--- a/counter/main.py
+++ b/counter/main.py
@@ -5,7 +5,7 @@
os.sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
-from xonfig import get_option
+from appconfig import get_option
API_URL = get_option('ESEARCH_API', 'URL')
API_TOKEN = get_option('ESEARCH_API', 'TOKEN')
diff --git a/react_app/config/env.js b/react_app/config/env.js
deleted file mode 100644
index 30a6c7f..0000000
--- a/react_app/config/env.js
+++ /dev/null
@@ -1,93 +0,0 @@
-'use strict';
-
-const fs = require('fs');
-const path = require('path');
-const paths = require('./paths');
-
-// Make sure that including paths.js after env.js will read .env variables.
-delete require.cache[require.resolve('./paths')];
-
-const NODE_ENV = process.env.NODE_ENV;
-if (!NODE_ENV) {
- throw new Error(
- 'The NODE_ENV environment variable is required but was not specified.'
- );
-}
-
-// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
-var dotenvFiles = [
- `${paths.dotenv}.${NODE_ENV}.local`,
- `${paths.dotenv}.${NODE_ENV}`,
- // Don't include `.env.local` for `test` environment
- // since normally you expect tests to produce the same
- // results for everyone
- NODE_ENV !== 'test' && `${paths.dotenv}.local`,
- paths.dotenv,
-].filter(Boolean);
-
-// Load environment variables from .env* files. Suppress warnings using silent
-// if this file is missing. dotenv will never modify any environment variables
-// that have already been set. Variable expansion is supported in .env files.
-// https://github.com/motdotla/dotenv
-// https://github.com/motdotla/dotenv-expand
-dotenvFiles.forEach(dotenvFile => {
- if (fs.existsSync(dotenvFile)) {
- require('dotenv-expand')(
- require('dotenv').config({
- path: dotenvFile,
- })
- );
- }
-});
-
-// We support resolving modules according to `NODE_PATH`.
-// This lets you use absolute paths in imports inside large monorepos:
-// https://github.com/facebookincubator/create-react-app/issues/253.
-// It works similar to `NODE_PATH` in Node itself:
-// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
-// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
-// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
-// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
-// We also resolve them to make sure all tools using them work consistently.
-const appDirectory = fs.realpathSync(process.cwd());
-process.env.NODE_PATH = (process.env.NODE_PATH || '')
- .split(path.delimiter)
- .filter(folder => folder && !path.isAbsolute(folder))
- .map(folder => path.resolve(appDirectory, folder))
- .join(path.delimiter);
-
-// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
-// injected into the application via DefinePlugin in Webpack configuration.
-const REACT_APP = /^REACT_APP_/i;
-
-function getClientEnvironment(publicUrl) {
- const raw = Object.keys(process.env)
- .filter(key => REACT_APP.test(key))
- .reduce(
- (env, key) => {
- env[key] = process.env[key];
- return env;
- },
- {
- // Useful for determining whether we’re running in production mode.
- // Most importantly, it switches React into the correct mode.
- NODE_ENV: process.env.NODE_ENV || 'development',
- // Useful for resolving the correct path to static assets in `public`.
- // For example, .
- // This should only be used as an escape hatch. Normally you would put
- // images into the `src` and `import` them in code to get their paths.
- PUBLIC_URL: publicUrl,
- }
- );
- // Stringify all values so we can feed into Webpack DefinePlugin
- const stringified = {
- 'process.env': Object.keys(raw).reduce((env, key) => {
- env[key] = JSON.stringify(raw[key]);
- return env;
- }, {}),
- };
-
- return { raw, stringified };
-}
-
-module.exports = getClientEnvironment;
diff --git a/react_app/config/jest/cssTransform.js b/react_app/config/jest/cssTransform.js
deleted file mode 100644
index 8f65114..0000000
--- a/react_app/config/jest/cssTransform.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-// This is a custom Jest transformer turning style imports into empty objects.
-// http://facebook.github.io/jest/docs/en/webpack.html
-
-module.exports = {
- process() {
- return 'module.exports = {};';
- },
- getCacheKey() {
- // The output is always the same.
- return 'cssTransform';
- },
-};
diff --git a/react_app/config/jest/fileTransform.js b/react_app/config/jest/fileTransform.js
deleted file mode 100644
index 9e4047d..0000000
--- a/react_app/config/jest/fileTransform.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict';
-
-const path = require('path');
-
-// This is a custom Jest transformer turning file imports into filenames.
-// http://facebook.github.io/jest/docs/en/webpack.html
-
-module.exports = {
- process(src, filename) {
- return `module.exports = ${JSON.stringify(path.basename(filename))};`;
- },
-};
diff --git a/react_app/config/paths.js b/react_app/config/paths.js
deleted file mode 100644
index 6d16efc..0000000
--- a/react_app/config/paths.js
+++ /dev/null
@@ -1,55 +0,0 @@
-'use strict';
-
-const path = require('path');
-const fs = require('fs');
-const url = require('url');
-
-// Make sure any symlinks in the project folder are resolved:
-// https://github.com/facebookincubator/create-react-app/issues/637
-const appDirectory = fs.realpathSync(process.cwd());
-const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
-
-const envPublicUrl = process.env.PUBLIC_URL;
-
-function ensureSlash(path, needsSlash) {
- const hasSlash = path.endsWith('/');
- if (hasSlash && !needsSlash) {
- return path.substr(path, path.length - 1);
- } else if (!hasSlash && needsSlash) {
- return `${path}/`;
- } else {
- return path;
- }
-}
-
-const getPublicUrl = appPackageJson =>
- envPublicUrl || require(appPackageJson).homepage;
-
-// We use `PUBLIC_URL` environment variable or "homepage" field to infer
-// "public path" at which the app is served.
-// Webpack needs to know it to put the right
+
+
+