mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 07:18:26 +01:00
improve docker image
This commit is contained in:
parent
f986884f85
commit
8d8b098d86
3 changed files with 50 additions and 126 deletions
106
p/Dockerfile
106
p/Dockerfile
|
@ -1,99 +1,21 @@
|
||||||
#################################################################################
|
# docker build -t pproxy .
|
||||||
# INSTALLERS #
|
# docker run -p 6003:6003 -v ./whitelist.json:/pproxy/whitelist.json:ro pproxy
|
||||||
# These images provide the dependencies required to build the other images. #
|
|
||||||
#################################################################################
|
|
||||||
|
|
||||||
FROM quay.io/almalinuxorg/9-base AS builder-installer
|
# Base
|
||||||
|
FROM node:18-alpine
|
||||||
|
|
||||||
# Needed for node 18+
|
# Install dependencies
|
||||||
# RUN dnf module --assumeyes enable nodejs
|
RUN apk add --no-cache git build-base python3
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/var/cache/dnf \
|
# Set Work Directory
|
||||||
dnf install --assumeyes --nodocs nodejs ca-certificates jq make gcc g++
|
WORKDIR /pproxy
|
||||||
|
|
||||||
RUN npm install -g \
|
# Install dependencies
|
||||||
npm@$(curl "https://release-monitoring.org/api/v2/versions/?project_id=190206" | jq --raw-output '.stable_versions[0]')
|
# Honestly less effort this way
|
||||||
|
RUN yarn add express undici
|
||||||
|
|
||||||
|
# Copy files
|
||||||
|
COPY server.js .
|
||||||
|
|
||||||
# Runtime dependencies
|
# Entrypoint
|
||||||
FROM quay.io/almalinuxorg/9-base AS installer
|
|
||||||
|
|
||||||
COPY --from=quay.io/almalinuxorg/9-micro / /rpms
|
|
||||||
RUN --mount=type=cache,target=/var/cache/dnf \
|
|
||||||
dnf install --assumeyes \
|
|
||||||
--installroot /rpms \
|
|
||||||
--releasever=9 \
|
|
||||||
--setopt=install_weak_deps=false \
|
|
||||||
--nodocs \
|
|
||||||
nodejs ca-certificates
|
|
||||||
|
|
||||||
RUN dnf clean all \
|
|
||||||
--installroot /rpms
|
|
||||||
|
|
||||||
|
|
||||||
# Proxy + certbot
|
|
||||||
FROM quay.io/almalinuxorg/9-base AS proxy-installer
|
|
||||||
|
|
||||||
RUN dnf install epel-release --assumeyes
|
|
||||||
|
|
||||||
COPY --from=quay.io/almalinuxorg/9-micro / /rpms
|
|
||||||
RUN --mount=type=cache,target=/var/cache/dnf \
|
|
||||||
dnf install --assumeyes \
|
|
||||||
--installroot /rpms \
|
|
||||||
--releasever=9 \
|
|
||||||
--setopt=install_weak_deps=false \
|
|
||||||
--setopt=reposdir=/etc/yum.repos.d \
|
|
||||||
--nodocs \
|
|
||||||
nginx-core certbot python3-certbot-nginx
|
|
||||||
|
|
||||||
RUN dnf clean all \
|
|
||||||
--installroot /rpms
|
|
||||||
|
|
||||||
#################################################################################
|
|
||||||
# BUILDER #
|
|
||||||
#################################################################################
|
|
||||||
|
|
||||||
FROM builder-installer AS builder
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
COPY package.json ./
|
|
||||||
RUN npm install --frozen-lockfile
|
|
||||||
# COPY ./ ./
|
|
||||||
COPY p/server.js ./
|
|
||||||
|
|
||||||
#################################################################################
|
|
||||||
# FINAL IMAGE #
|
|
||||||
#################################################################################
|
|
||||||
|
|
||||||
FROM quay.io/almalinuxorg/9-micro AS release-base
|
|
||||||
|
|
||||||
# Grab npm
|
|
||||||
COPY --from=installer /rpms /
|
|
||||||
|
|
||||||
# Grab site
|
|
||||||
COPY --from=builder /usr/src/app /app
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ENV NODE_ENV production
|
|
||||||
|
|
||||||
|
|
||||||
# Final image
|
|
||||||
FROM release-base as release
|
|
||||||
# EXPOSE 3000/tcp
|
|
||||||
CMD [ "node", "server.js" ]
|
|
||||||
|
|
||||||
# Final image with extras
|
|
||||||
FROM release-base AS release-aio
|
|
||||||
# Grab nginx and certbot
|
|
||||||
COPY --from=proxy-installer /rpms /
|
|
||||||
|
|
||||||
COPY entrypoint.sh entrypoint.sh
|
|
||||||
RUN chmod +x entrypoint.sh
|
|
||||||
COPY nginx.conf.example /etc/nginx/conf.d/poketube.conf
|
|
||||||
|
|
||||||
# EXPOSE 80/tcp
|
|
||||||
# EXPOSE 443/tcp
|
|
||||||
ENTRYPOINT [ "/usr/bin/bash", "./entrypoint.sh" ]
|
|
||||||
CMD [ "node", "server.js" ]
|
CMD [ "node", "server.js" ]
|
36
p/server.js
36
p/server.js
|
@ -1,41 +1,10 @@
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const fetch = require("node-fetch");
|
// const fetch = require("node-fetch");
|
||||||
const { URL } = require("url");
|
const { URL } = require("url");
|
||||||
const { Readable } = require("node:stream");
|
const { Readable } = require("node:stream");
|
||||||
|
|
||||||
// Array of hostnames that will be proxied
|
// Array of hostnames that will be proxied
|
||||||
const URL_WHITELIST = [
|
const URL_WHITELIST = require("./whitelist.json");
|
||||||
"i.ytimg.com",
|
|
||||||
"yt3.googleusercontent.com",
|
|
||||||
"cdn.glitch.global",
|
|
||||||
"cdn.statically.io",
|
|
||||||
"site-assets.fontawesome.com",
|
|
||||||
"fonts.gstatic.com",
|
|
||||||
"cdn.jsdelivr.net",
|
|
||||||
"yt3.ggpht.com",
|
|
||||||
"tube.kuylar.dev",
|
|
||||||
"lh3.googleusercontent.com",
|
|
||||||
"is4-ssl.mzstatic.com",
|
|
||||||
"is2-ssl.mzstatic.com",
|
|
||||||
"is1-ssl.mzstatic.com",
|
|
||||||
"fonts.bunny.net",
|
|
||||||
"demo.matomo.org",
|
|
||||||
"is5-ssl.mzstatic.com",
|
|
||||||
"is3-ssl.mzstatic.com",
|
|
||||||
"twemoji.maxcdn.com",
|
|
||||||
"unpkg.com",
|
|
||||||
"lite.duckduckgo.com",
|
|
||||||
"youtube.com",
|
|
||||||
"returnyoutubedislikeapi.com",
|
|
||||||
"cdn.zptr.cc",
|
|
||||||
"inv.vern.cc",
|
|
||||||
"invidious.privacydev.net",
|
|
||||||
"inv.zzls.xyz",
|
|
||||||
"vid.puffyan.us",
|
|
||||||
"invidious.lidarshield.cloud",
|
|
||||||
"invidious.epicsite.xyz",
|
|
||||||
"invidious.esmailelbob.xyz",
|
|
||||||
];
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
@ -162,6 +131,7 @@ const { fetch } = await import("undici")
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/bangs", async (req, res) => {
|
app.get("/bangs", async (req, res) => {
|
||||||
|
const { fetch } = await import("undici")
|
||||||
|
|
||||||
let f = await fetch("https://lite.duckduckgo.com/lite/?q=" + req.query.q, {
|
let f = await fetch("https://lite.duckduckgo.com/lite/?q=" + req.query.q, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
|
32
p/whitelist.json
Normal file
32
p/whitelist.json
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
[
|
||||||
|
"i.ytimg.com",
|
||||||
|
"yt3.googleusercontent.com",
|
||||||
|
"cdn.glitch.global",
|
||||||
|
"cdn.statically.io",
|
||||||
|
"site-assets.fontawesome.com",
|
||||||
|
"fonts.gstatic.com",
|
||||||
|
"cdn.jsdelivr.net",
|
||||||
|
"yt3.ggpht.com",
|
||||||
|
"tube.kuylar.dev",
|
||||||
|
"lh3.googleusercontent.com",
|
||||||
|
"is4-ssl.mzstatic.com",
|
||||||
|
"is2-ssl.mzstatic.com",
|
||||||
|
"is1-ssl.mzstatic.com",
|
||||||
|
"fonts.bunny.net",
|
||||||
|
"demo.matomo.org",
|
||||||
|
"is5-ssl.mzstatic.com",
|
||||||
|
"is3-ssl.mzstatic.com",
|
||||||
|
"twemoji.maxcdn.com",
|
||||||
|
"unpkg.com",
|
||||||
|
"lite.duckduckgo.com",
|
||||||
|
"youtube.com",
|
||||||
|
"returnyoutubedislikeapi.com",
|
||||||
|
"cdn.zptr.cc",
|
||||||
|
"inv.vern.cc",
|
||||||
|
"invidious.privacydev.net",
|
||||||
|
"inv.zzls.xyz",
|
||||||
|
"vid.puffyan.us",
|
||||||
|
"invidious.lidarshield.cloud",
|
||||||
|
"invidious.epicsite.xyz",
|
||||||
|
"invidious.esmailelbob.xyz"
|
||||||
|
]
|
Loading…
Reference in a new issue