FROM alpine:3.10 AS elm-builder ARG ELM_VERSION=0.19.1 ARG ELM_URL=https://github.com/elm/compiler/releases/download/${ELM_VERSION}/binary-for-linux-64-bit.gz # Download internet packages + Node & npm RUN apk add --no-cache ca-certificates curl gzip bash nodejs npm # Download & install Elm RUN curl -L ${ELM_URL} \ | gunzip > /usr/local/bin/elm \ && chmod +x /usr/local/bin/elm # Install uglify-js globally RUN npm install -g uglify-js WORKDIR /app # Copy Elm code COPY elm.json . COPY elm/ elm/ # Compile module RUN elm make --output=/app/elm.js --optimize elm/EloTracker.elm # Optimize & Minify compiled JS RUN uglifyjs elm.js \ --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" \ | uglifyjs --mangle --output elo_tracker.js FROM python:3.10-alpine AS python-builder WORKDIR /app # Install build dependencies RUN apk add --no-cache gcc musl-dev python3-dev COPY requirements-elo.txt . # Create wheels for faster installation RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements-elo.txt FROM python:3.10-alpine WORKDIR /app # Install from pre-built wheels COPY --from=python-builder /wheels /wheels COPY requirements-elo.txt . RUN pip install --no-cache-dir --no-index --find-links=/wheels \ -r requirements-elo.txt && rm -rf /wheels # Install Elm front-end JS COPY --from=elm-builder /app/elo_tracker.js /app/elo_tracker/static/elo_tracker.js # Install ELO tracker code COPY agents/ agents/ COPY elo_tracker/ elo_tracker/ COPY pyclient/ pyclient/ COPY pyserver/ pyserver/ COPY elo.py . CMD ["python", "elo.py"]