forked from mtusi2026/mtusi2026lab5
на оценку 5
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
FROM haproxy:3.2-alpine@sha256:dfba86f031bd4c9039f10f8cc5de75991d1b6766d5460f0335b980408503baad
|
||||
|
||||
COPY infrastructure/haproxy/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
|
||||
|
||||
USER haproxy
|
||||
|
||||
EXPOSE 8080
|
||||
@@ -0,0 +1,66 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 2048
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
timeout connect 1s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold other 1s
|
||||
hold refused 1s
|
||||
hold nx 1s
|
||||
hold timeout 1s
|
||||
hold obsolete 1s
|
||||
|
||||
frontend public
|
||||
bind :8080
|
||||
|
||||
acl api_request path_beg /api/ /web-api/ /health/
|
||||
acl web_api path_beg /web-api/
|
||||
acl has_session req.cook(mtusi_session) -m found
|
||||
acl message_create method POST
|
||||
acl message_path path_reg ^/(api|web-api)/v1/chats/[^/]+/messages$
|
||||
|
||||
http-request del-header Authorization if web_api
|
||||
http-request set-header Authorization "Bearer %[req.cook(mtusi_session)]" if web_api has_session
|
||||
http-request del-header Cookie if api_request
|
||||
http-request replace-path ^/web-api/(.*)$ /api/\1 if web_api
|
||||
|
||||
use_backend message_backend if message_create message_path
|
||||
use_backend api_backend if api_request
|
||||
default_backend frontend_backend
|
||||
|
||||
backend api_backend
|
||||
balance leastconn
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/lb ver HTTP/1.1 hdr Host api
|
||||
http-check expect status 200
|
||||
default-server check inter 1s fastinter 500ms downinter 1s fall 2 rise 2 resolvers docker init-addr libc,none
|
||||
server-template api 8 api:8080
|
||||
|
||||
backend message_backend
|
||||
balance leastconn
|
||||
option httpchk
|
||||
option redispatch
|
||||
option http-buffer-request
|
||||
retries 3
|
||||
retry-on conn-failure empty-response response-timeout 502 503 504
|
||||
http-check send meth GET uri /health/lb ver HTTP/1.1 hdr Host api
|
||||
http-check expect status 200
|
||||
default-server check inter 1s fastinter 500ms downinter 1s fall 2 rise 2 resolvers docker init-addr libc,none
|
||||
server-template api 8 api:8080
|
||||
|
||||
backend frontend_backend
|
||||
option httpchk GET /
|
||||
http-check expect status 200
|
||||
server frontend frontend:8080 check inter 2s fall 2 rise 2 resolvers docker init-addr libc,none
|
||||
@@ -0,0 +1,40 @@
|
||||
FROM golang:1.27.1-alpine@sha256:8a5910f31396cd4d89662f56c68b3ae31d374308270a1c3bd96672ee5ed43414 AS minio-builder
|
||||
|
||||
ARG MINIO_VERSION=RELEASE.2025-10-15T17-29-55Z
|
||||
RUN CGO_ENABLED=0 GOBIN=/out go install github.com/minio/minio@${MINIO_VERSION}
|
||||
|
||||
FROM golang:1.27.1-alpine@sha256:8a5910f31396cd4d89662f56c68b3ae31d374308270a1c3bd96672ee5ed43414 AS mc-builder
|
||||
|
||||
ARG MC_VERSION=RELEASE.2025-08-13T08-35-41Z
|
||||
RUN CGO_ENABLED=0 GOBIN=/out go install github.com/minio/mc@${MC_VERSION}
|
||||
|
||||
FROM alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6 AS server
|
||||
|
||||
RUN apk add --no-cache ca-certificates wget && \
|
||||
addgroup -g 1000 minio && \
|
||||
adduser -u 1000 -G minio -s /sbin/nologin -D minio && \
|
||||
mkdir -p /data && \
|
||||
chown minio:minio /data
|
||||
|
||||
COPY --from=minio-builder /out/minio /usr/local/bin/minio
|
||||
|
||||
USER minio:minio
|
||||
VOLUME ["/data"]
|
||||
EXPOSE 9000
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=20 \
|
||||
CMD wget -qO- http://127.0.0.1:9000/minio/health/live >/dev/null || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/minio"]
|
||||
CMD ["server", "/data", "--address", ":9000"]
|
||||
|
||||
FROM alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6 AS client
|
||||
|
||||
RUN apk add --no-cache ca-certificates && \
|
||||
addgroup -g 1000 minio && \
|
||||
adduser -u 1000 -G minio -s /sbin/nologin -D minio
|
||||
|
||||
COPY --from=mc-builder /out/mc /usr/local/bin/mc
|
||||
|
||||
USER minio:minio
|
||||
ENTRYPOINT ["/usr/local/bin/mc"]
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetBucketLocation",
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::__BUCKET__"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:PutObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::__BUCKET__/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
FROM node:24-alpine@sha256:44fce696f38ba8c987c4db89954051000bbd05ffd8d8659ba15ed4a8602e937f AS frontend-build
|
||||
|
||||
WORKDIR /frontend
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend/ ./
|
||||
RUN npm test && npm run build
|
||||
|
||||
FROM nginx:1.30.6-alpine@sha256:970364228b1e4f932abc22d321932816782cca8a20b85a77552a7cfe9acfb3b5
|
||||
|
||||
COPY infrastructure/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=frontend-build /frontend/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 8080
|
||||
@@ -0,0 +1,32 @@
|
||||
worker_processes auto;
|
||||
|
||||
events {
|
||||
worker_connections 512;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
|
||||
|
||||
location /assets/ {
|
||||
try_files $uri =404;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user