Skip to content

Commit

Permalink
add: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ActivePeter committed Dec 5, 2023
1 parent 955986c commit 88a0e32
Show file tree
Hide file tree
Showing 429 changed files with 64,674 additions and 58,973 deletions.
1 change: 1 addition & 0 deletions pa_note_web/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
authority_config.json
20 changes: 20 additions & 0 deletions pa_note_web/docker/Dockerfile.Front
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# FROM node:16.20.0 AS builder

# WORKDIR /src
# COPY pa_note_front /src

# RUN ls
# RUN npm install -g pnpm
# RUN pnpm install
# RUN pnpm build

FROM nginx:alpine-slim

RUN mkdir -p /usr/share/nginx/front/dist

COPY docker/front_nginx.conf /etc/nginx/nginx.conf

# COPY --from=builder /src/dist /usr/share/nginx/front/dist
COPY pa_note_front/dist /usr/share/nginx/front/dist

EXPOSE 3333
14 changes: 14 additions & 0 deletions pa_note_web/docker/Dockerfile.Server
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM panote_server_builder:v1 AS builder

FROM rust:1.70 AS server


COPY --from=builder /src/target/release/pa_note_server /etc/server/pa_note_server
COPY docker/authority_config.json /etc/server

WORKDIR /etc/server
# RUN rustup default nightly
RUN chmod 775 ./pa_note_server

EXPOSE 3004
ENTRYPOINT ["./pa_note_server"]
6 changes: 6 additions & 0 deletions pa_note_web/docker/Dockerfile.ServerBuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM rust:1.70 AS builder

WORKDIR /src
COPY pa_note_server /src
RUN rustup default nightly
RUN cargo build --release
5 changes: 5 additions & 0 deletions pa_note_web/docker/authority_config_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id":"",
"pw":"",
"token_secret": ""
}
1 change: 1 addition & 0 deletions pa_note_web/docker/build_front.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build -f docker/Dockerfile.Front -t panote_front:v1 . --no-cache
1 change: 1 addition & 0 deletions pa_note_web/docker/build_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build -f docker/Dockerfile.Server -t panote_server:v1 . --no-cache
1 change: 1 addition & 0 deletions pa_note_web/docker/build_server_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build -f docker/Dockerfile.ServerBuilder -t panote_server_builder:v1 . --no-cache
24 changes: 24 additions & 0 deletions pa_note_web/docker/example_docker_compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'
services:
nginx:
image: nginx:alpine-slim
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs:/etc/nginx/certs:ro
depends_on:
- frontend
- backend

frontend:
image: panote_front:v1
ports:
- "3333:3333"

backend:
image: panote_server:v1
ports:
- "3004:3004"
volumes:
- ./panote_data:/etc/server/default
50 changes: 50 additions & 0 deletions pa_note_web/docker/example_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

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

server {
listen 80;

location / {
proxy_pass http://frontend:3333;
}

location /panote_api/ {
rewrite ^/panote_api(/.*)$ $1 break;
proxy_pass http://host.docker.internal:3004;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
#server {
# listen 443 ssl;
# ; server_name your_domain.com; # Replace with your actual domain
#
# ssl_certificate /etc/nginx/certs/fullchain.pem; # Replace with your SSL certificate path
# ssl_certificate_key /etc/nginx/certs/privkey.pem; # Replace with your SSL certificate key path
#
# location / {
# proxy_pass http://frontend:3333;
# }
#
# location /api {
# proxy_pass http://backend:3004;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# }
#}
}
3 changes: 3 additions & 0 deletions pa_note_web/docker/front_entry_point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd /etc/pa_note_front
npm install
npm run build
30 changes: 30 additions & 0 deletions pa_note_web/docker/front_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
worker_processes 1;

events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nodelay on;
keepalive_timeout 30;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 3333;
server_name localhost;
root /usr/share/nginx/front/dist;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location / {
try_files $uri $uri/ =404;
index index.html index.htm;
gzip_static on;
expires max;
add_header Cache-Control public;
if ($request_filename ~* ^.*?\.(eot)|(ttf)|(woff)|(svg)|(otf)$) {
add_header Access-Control-Allow-Origin *;
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 88a0e32

Please sign in to comment.