|
1 | | -# v0.4.5 |
2 | | -FROM vuls/go-exploitdb@sha256:4738ca739083d41b89aab11012e283f89645f5cdbb5c021f2fbb6584bd5fe423 |
| 1 | +FROM alpine:3.18 |
3 | 2 |
|
4 | | -# Make directory to store DB if not volume mounted |
5 | | -RUN mkdir /vuls |
| 3 | +ARG TARGETPLATFORM |
6 | 4 |
|
7 | | -# Set up a cron job to update the database files every 3 hours |
8 | | -RUN echo "0 */3 * * * /update.sh" >> /var/spool/cron/crontabs/root |
| 5 | +RUN apk --no-cache add git ca-certificates |
9 | 6 |
|
10 | | -# Make sure the cron job file has proper permissions |
11 | | -RUN chmod 0600 /var/spool/cron/crontabs/root |
| 7 | +ADD --link --chmod=600 crontabs/root /var/spool/cron/crontabs/root |
12 | 8 |
|
13 | | -# Copy updater script and make it executable |
14 | | -COPY update.sh /update.sh |
15 | | -RUN chmod +x /update.sh |
| 9 | +RUN <<EOT |
| 10 | + set -e |
16 | 11 |
|
17 | | -# Copy entry point script and make it executable |
18 | | -COPY entrypoint.sh /entrypoint.sh |
19 | | -RUN chmod +x /entrypoint.sh |
| 12 | + version=0.4.6 |
| 13 | + ## Install s6-overlay binaries |
| 14 | + case "$TARGETPLATFORM" in |
| 15 | + "linux/amd64") |
| 16 | + url=https://github.com/vulsio/go-exploitdb/releases/download/v${version}/go-exploitdb_${version}_linux_amd64.tar.gz |
| 17 | + checksum=b27cd43a1c194bb365c73d6e4bd199911d83aab4bf48a5eca4ecb8838c0daa9c |
| 18 | + ;; |
| 19 | + "linux/arm64") |
| 20 | + url=https://github.com/vulsio/go-exploitdb/releases/download/v${version}/go-exploitdb_${version}_linux_arm64.tar.gz |
| 21 | + checksum=432a51a12aebcd4350c4d10c1435cb0d7a5720a7a9bb204a109ccd6c10553184 |
| 22 | + ;; |
| 23 | + *) |
| 24 | + printf "ERROR: %s" "invalid architecture" |
| 25 | + exit 1 |
| 26 | + esac |
20 | 27 |
|
21 | | -# Use the entrypoint script to start freshclam, cron, and Nginx |
22 | | -ENTRYPOINT ["/entrypoint.sh"] |
| 28 | + archive="$(basename ${url})" |
| 29 | + wget -q -O "${archive}" "${url}" |
| 30 | + printf "%s %s" "${checksum}" "${archive}" | sha256sum -c - |
| 31 | + tar xzvf "${archive}" -C /usr/local/bin 'go-exploitdb' |
| 32 | + rm -f "${archive}" |
| 33 | + |
| 34 | + chown root:root /usr/local/bin/go-exploitdb |
| 35 | + chmod +x /usr/local/bin/go-exploitdb |
| 36 | + |
| 37 | + mkdir -p /etc/go-exploitdb /var/lib/go-exploitdb /var/log/go-exploitdb |
| 38 | +EOT |
| 39 | + |
| 40 | +ADD --link --chmod=644 go-exploitdb/go-exploitdb.yaml /etc/go-exploitdb/go-exploitdb.yaml |
| 41 | +ADD --link --chmod=755 go-exploitdb/go-exploitdb-update.sh /usr/local/bin/go-exploitdb-update |
| 42 | + |
| 43 | +VOLUME ["/etc/go-exploitdb", "/var/lib/go-exploitdb", "/var/log/go-exploitdb"] |
| 44 | + |
| 45 | +RUN <<EOT |
| 46 | + set -e |
| 47 | + |
| 48 | + version=3.1.6.2 |
| 49 | + url= |
| 50 | + checksum= |
| 51 | + |
| 52 | + ## Install s6-overlay scripts |
| 53 | + url=https://github.com/just-containers/s6-overlay/releases/download/v${version}/s6-overlay-noarch.tar.xz |
| 54 | + checksum=05af2536ec4fb23f087a43ce305f8962512890d7c71572ed88852ab91d1434e3 |
| 55 | + |
| 56 | + archive="$(basename ${url})" |
| 57 | + wget -q -O "${archive}" "${url}" |
| 58 | + printf "%s %s" "${checksum}" "${archive}" | sha256sum -c - |
| 59 | + tar -C / -Jxpf "${archive}" |
| 60 | + rm -f "${archive}" |
| 61 | + |
| 62 | + ## Install s6-overlay binaries |
| 63 | + case "$TARGETPLATFORM" in |
| 64 | + "linux/amd64") |
| 65 | + url=https://github.com/just-containers/s6-overlay/releases/download/v${version}/s6-overlay-x86_64.tar.xz |
| 66 | + checksum=95081f11c56e5a351e9ccab4e70c2b1c3d7d056d82b72502b942762112c03d1c |
| 67 | + ;; |
| 68 | + "linux/arm64") |
| 69 | + url=https://github.com/just-containers/s6-overlay/releases/download/v${version}/s6-overlay-aarch64.tar.xz |
| 70 | + checksum=3fc0bae418a0e3811b3deeadfca9cc2f0869fb2f4787ab8a53f6944067d140ee |
| 71 | + ;; |
| 72 | + *) |
| 73 | + printf "ERROR: %s" "invalid architecture" |
| 74 | + exit 1 |
| 75 | + esac |
| 76 | + |
| 77 | + archive="$(basename ${url})" |
| 78 | + wget -q -O "${archive}" "${url}" |
| 79 | + printf "%s %s" "${checksum}" "${archive}" | sha256sum -c - |
| 80 | + tar -C / -Jxpf "${archive}" |
| 81 | + rm -f "${archive}" |
| 82 | +EOT |
| 83 | + |
| 84 | +ADD --link --chmod=755 s6-rc.d/cron /etc/s6-overlay/s6-rc.d/cron |
| 85 | +ADD --link --chmod=755 s6-rc.d/go-exploitdb /etc/s6-overlay/s6-rc.d/go-exploitdb |
| 86 | +ADD --link --chmod=755 s6-rc.d/go-exploitdb-updater /etc/s6-overlay/s6-rc.d/go-exploitdb-updater |
| 87 | +ADD --link --chmod=755 s6-rc.d/user/contents.d/* /etc/s6-overlay/s6-rc.d/user/contents.d/ |
| 88 | + |
| 89 | +ENV S6_KEEP_ENV 1 |
| 90 | +# Stop container if any of the services fail to start at boot. |
| 91 | +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 |
| 92 | +ENV S6_VERBOSITY 1 |
| 93 | +# Stop container if services are not started in 10 mins. |
| 94 | +ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME 600000 |
| 95 | + |
| 96 | +ENTRYPOINT ["/init"] |
0 commit comments