Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
120 lines (116 loc) · 4.96 KB
/
Copy pathdocker-compose.yml
File metadata and controls
120 lines (116 loc) · 4.96 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
services:
clamav:
image: clamav/clamav:stable
volumes:
- clamav-data:/var/lib/clamav
# Raises clamd's stock stream limit to comfortably cover one scan
# window (metadata.json, or a 1 GiB window of a log entry plus its
# 1 MiB overlap), and makes it report content it skipped for
# exceeding a limit instead of answering OK — see the file's own
# header. Note this replaces the image's config wholesale, so
# anything the stock file set is gone unless clamd.conf sets it too.
- ./clamd.conf:/etc/clamav/clamd.conf:ro
# clamd spools each INSTREAM body here (TemporaryDirectory in
# clamd.conf). On the container's writable layer, concurrent ~1 GiB
# scan windows across concurrent uploads would eat the host's Docker
# storage instead.
- clamav-tmp:/var/tmp/clamav
# clamd holds the whole signature database resident (~1-2 GB). Without
# a ceiling a spike takes the host down with it; with one, the
# container is the only casualty and the portal 503s until it is back.
mem_limit: 4g
healthcheck:
test: ["CMD", "clamdcheck.sh"]
interval: 30s
timeout: 10s
# Budget generously: the portal has `condition: service_healthy`, so
# exhausting these retries doesn't just delay startup, it fails the
# portal container outright. A first-boot CVD download on a slow
# link is the case that overruns.
retries: 20
start_period: 300s # first boot downloads the virus database
minio:
image: minio/minio:latest
command: server /data --address ":9001" --console-address ":9002"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
volumes:
- minio-data:/data
minio-init:
image: minio/mc:latest
depends_on:
- minio
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
S3_BUCKET: ${S3_BUCKET:-submissions}
entrypoint: >
sh -c "
until mc alias set local http://minio:9001 \"$$MINIO_ROOT_USER\" \"$$MINIO_ROOT_PASSWORD\"; do sleep 1; done &&
mc mb --ignore-existing local/$$S3_BUCKET
"
portal:
build:
context: .
dockerfile: Dockerfile
depends_on:
minio-init:
condition: service_completed_successfully
clamav:
condition: service_healthy
environment:
ADMIN_OPERATOR_ADDRESSES: ${ADMIN_OPERATOR_ADDRESSES}
ADMIN_SESSION_SECRET: ${ADMIN_SESSION_SECRET:-}
SESSION_SECRET: ${SESSION_SECRET:-}
S3_ACCESS_KEY: ${MINIO_ROOT_USER}
S3_SECRET_KEY: ${MINIO_ROOT_PASSWORD}
command:
- -remote=${REMOTE}
- -addr=0.0.0.0:8888
- -s3-bucket=${S3_BUCKET:-submissions}
- -s3-region=us-east-1
- -s3-endpoint=http://minio:9001
- -log-path=/data/submissions.jsonl
- -exercise-path=/data/exercise.json
- -scores-path=/data/scores.json
- -clamav-addr=clamav:3310
- -clamav-timeout=15m
# The upload authenticates once, when the request starts, but the page
# re-authenticates on every progress poll — so a TTL shorter than a
# submission takes leaves the submission running while its progress
# display goes dark. A 4 GiB archive transfers, validates, scans and
# stores well past the 5-minute default, so this covers the worst case
# the upload ceiling allows rather than the typical one.
- -session-ttl=${SESSION_TTL:-2h}
# 4 GiB. clamd never sees more than a 1 GiB scan window of this at a
# time, so raising it further is a disk/S3/time question, not a
# clamd.conf one — see README.md's "Upload size and ClamAV".
# Source of truth: cmd/portal/main.go's defaultMaxUploadSize
# constant; this file can't import a Go constant, so keep the two
# numbers in step by hand.
- -max-upload-size=${MAX_UPLOAD_SIZE:-4294967296}
# 4 GiB, matching MAX_UPLOAD_SIZE. Applies per log entry
# (validator.log.gz, sentry.log.gz). Streamed, not buffered — see
# submission.ValidateArchive and submission.ScanLogs. The ceiling
# here is decompression work, not resident memory.
# Source of truth: cmd/portal/main.go's defaultMaxLogSize constant;
# this file can't import a Go constant, so keep the two numbers in
# step by hand.
- -max-log-size=${MAX_LOG_SIZE:-4294967296}
# Decompressed bytes of log content the antivirus may examine per
# submission, shared across validator.log.gz and sentry.log.gz under
# one budget. Past this the submission is accepted and recorded as
# partially scanned — the cap is bomb defence, not cost control.
# Source of truth: clamav.DefaultScanBudget; this file can't import
# a Go constant, so keep the two numbers in step by hand.
- -av-scan-budget=${AV_SCAN_BUDGET:-34359738368}
volumes:
- portal-logs:/data
ports:
- "${PORTAL_PORT:-8080}:8888"
volumes:
minio-data:
portal-logs:
clamav-data:
clamav-tmp: