GoTest / Dockerfile
edwagbb's picture
Update Dockerfile
39d177e verified
FROM ghcr.io/aurora-develop/aurora:latest AS builder
FROM debian
WORKDIR /app
COPY --from=builder /app/aurora /app/aurora
COPY --from=builder /app/harPool /app/harPool
RUN apt-get update -y && apt-get install -y nodejs npm
RUN npm install express http-proxy-middleware
COPY anakin_proxy_linux_amd64 /app/anakin
COPY <<EOF /app/index.js
const express = require("express");
const app = express();
const { createProxyMiddleware } = require("http-proxy-middleware");
function authMiddleware(req, res, next) {
res.setHeader('Access-Control-Allow-Origin','*');
res.setHeader('Access-Control-Allow-Headers','*');
if(req.method === "OPTIONS") return res.status(204).end();
if (!process.env.authorization || (req.headers.authorization||req.url).indexOf(process.env.authorization)>-1) {
next();
} else {
res.status(401).json({ error: 'Unauthorized' });
}
}
app.use(authMiddleware);
app.use(
"/aurora",
createProxyMiddleware({
target: "http://127.0.0.1:8080/",
changeOrigin: true,
pathRewrite: {
'^/aurora': '',
},
})
);
app.use(
"/anakin",
createProxyMiddleware({
target: "http://127.0.0.1:8000/",
changeOrigin: true,
pathRewrite: {
'^/anakin': '',
},
})
);
app.listen(7860, () => console.log(`Example app listening on port ${port}!`));
EOF
RUN chmod -R u+rwx,g+rwx,o+rwx /app
CMD /app/aurora & /app/anakin & node /app/index.js