Compare commits
1 Commits
main
...
build/dock
| Author | SHA1 | Date | |
|---|---|---|---|
| c05c74e412 |
11
.dockerignore
Normal file
11
.dockerignore
Normal file
@@ -0,0 +1,11 @@
|
||||
node_modules
|
||||
dist
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
.git/
|
||||
.githooks/
|
||||
__mocks__/
|
||||
test/
|
||||
eslint.config.js
|
||||
jest.config.js
|
||||
README.md
|
||||
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
# --- Building static files ---
|
||||
FROM node:23-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
|
||||
# --- Serving ---
|
||||
FROM nginx:alpine
|
||||
|
||||
RUN mkdir -p /app/www
|
||||
|
||||
COPY --from=build /app/dist /app/www
|
||||
|
||||
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
||||
|
||||
RUN adduser -D -H -u 1001 -s /sbin/nologin webuser
|
||||
|
||||
RUN chown -R webuser:webuser /app/www && \
|
||||
chmod -R 755 /app/www && \
|
||||
chown -R webuser:webuser /var/cache/nginx && \
|
||||
chown -R webuser:webuser /var/log/nginx && \
|
||||
chown -R webuser:webuser /etc/nginx/conf.d && \
|
||||
touch /var/run/nginx.pid && \
|
||||
chown -R webuser:webuser /var/run/nginx.pid && \
|
||||
chmod -R 777 /etc/nginx/conf.d
|
||||
|
||||
ENV PORT=80
|
||||
ENV NGINX_ENVSUBST_TEMPLATE_DIR=/etc/nginx/templates
|
||||
ENV NGINX_ENVSUBST_TEMPLATE_SUFFIX=.template
|
||||
ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/conf.d
|
||||
# Default value, potentially overwritten in compose file
|
||||
ENV BACKEND_ADDRESS="http://localhost:8000"
|
||||
|
||||
EXPOSE ${PORT}
|
||||
|
||||
USER webuser
|
||||
|
||||
CMD [ "nginx", "-g", "daemon off;" ]
|
||||
26
nginx.conf
Normal file
26
nginx.conf
Normal file
@@ -0,0 +1,26 @@
|
||||
server {
|
||||
listen ${PORT};
|
||||
server_name localhost;
|
||||
root /app/www;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
|
||||
# Compression
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
expires -1;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location /assets {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export default function Robot() {
|
||||
|
||||
const sendMessage = async () => {
|
||||
try {
|
||||
const response = await fetch("http://localhost:8000/message", {
|
||||
const response = await fetch(`${process.env.BACKEND_ADDRESS}/message`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -25,7 +25,7 @@ export default function Robot() {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const eventSource = new EventSource("http://localhost:8000/sse");
|
||||
const eventSource = new EventSource(`${process.env.BACKEND_ADDRESS}/sse`);
|
||||
|
||||
eventSource.onmessage = (event) => {
|
||||
try {
|
||||
|
||||
@@ -3,11 +3,17 @@
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"lib": [
|
||||
"ES2022",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"types": ["vite/client"],
|
||||
"types": [
|
||||
"vite/client",
|
||||
"node"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
@@ -15,7 +21,6 @@
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
@@ -24,5 +29,8 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src","test"]
|
||||
"include": [
|
||||
"src",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user