Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
/.venv/
wallets-v2.proxy.json
origins.json
/server/nginx.conf
34 changes: 6 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,29 @@
FROM python:3.11-alpine AS builder

RUN pip install jinja2

WORKDIR /build

COPY server/nginx.conf.j2 /build/nginx.conf.j2
COPY server/nginx.conf /build/nginx.conf
COPY wallets-v2.json /build/wallets-v2.json
COPY wallets.json /build/wallets.json
COPY scripts/proxy_urls.py /build/proxy_urls.py
COPY scripts/generate_nginx_conf.py /build/generate_nginx_conf.py

ARG ASSETS_PREFIX=assets
ARG SERVER_NAME=config.ton.org
ARG CACHE_DURATION_OK=10m
ARG CACHE_DURATION_NOTOK=2m

RUN python proxy_urls.py \
--input wallets-v2.json \
--output wallets-v2.proxy.json \
--origins origins.json \
--base-url "https://${SERVER_NAME}/${ASSETS_PREFIX}/"

RUN python generate_nginx_conf.py \
--template nginx.conf.j2 \
--origins origins.json \
--output nginx.conf \
--assets-prefix "${ASSETS_PREFIX}" \
--server-name "${SERVER_NAME}" \
--cache-duration-ok "${CACHE_DURATION_OK}" \
--cache-duration-notok "${CACHE_DURATION_NOTOK}"
--base-url "https://${SERVER_NAME}/assets/"

FROM nginx:alpine

ARG ASSETS_PREFIX=assets

ENV NGINX_RESOLVER=8.8.8.8
RUN rm /usr/share/nginx/html/*

COPY --from=builder /build/nginx.conf /etc/nginx/nginx.conf.template
COPY --from=builder /build/nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /build/wallets-v2.proxy.json /usr/share/nginx/html/wallets-v2.json
COPY --from=builder /build/wallets.json /usr/share/nginx/html/wallets.json
COPY assets/ /var/www/predownloaded_images/${ASSETS_PREFIX}/
COPY assets/ /usr/share/nginx/html/assets/

RUN mkdir -p /var/cache/nginx/image_cache && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/www/predownloaded_images

EXPOSE 80

CMD envsubst '${NGINX_RESOLVER}' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && \
nginx -g "daemon off;"
CMD nginx -g "daemon off;"
Binary file removed assets/.proxytest-404.png
Binary file not shown.
Binary file removed assets/.proxytest-dns.png
Binary file not shown.
2 changes: 0 additions & 2 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ version: '3.8'
services:
ton-wallets:
image: ${IMAGE:-ton-wallets-local}
environment:
NGINX_RESOLVER: 1.1.1.1
ports:
- "${TEST_PORT:-8088}:80"
healthcheck:
Expand Down
173 changes: 0 additions & 173 deletions scripts/generate_nginx_conf.py

This file was deleted.

40 changes: 40 additions & 0 deletions server/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
worker_processes auto;
pid /var/run/nginx.pid;
error_log /dev/stdout warn;

events {
worker_connections 1024;
use epoll;
multi_accept on;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';

access_log /dev/stdout main;

server {
listen 80;
server_name _;

root /usr/share/nginx/html;

location /assets/ {
try_files $uri =404;
add_header Cache-Control "public, max-age=1800"; # 15 minutes
}

location / {
try_files $uri $uri/ =404;
}

location = / {
autoindex on;
}
}
}
101 changes: 0 additions & 101 deletions server/nginx.conf.j2

This file was deleted.

Loading