How to build a node server image?

Time:2022-1-5

First, docker the node server and directly add dockerfile to the project.
The configuration file of nginx is as follows

server {

listen 80;
server_name example.org;
server_tokens off;
location /.well-known/acme-challenge/ {
    root /var/www/certbot;
}
location / {
    return 301 
}

}
server {

listen 443 ssl;
server_name example.org;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
    proxy_pass  
    proxy_set_header    Host                $http_host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
}

}
Assembling node server + nginx
We have now obtained an nginx with a legal certificateWebpage GameConnect the node server to the back of nginx. We directly provided docker – compose. In the previous boilerplate YML makes some changes.

version: “3”
services:
nodeapp:

image: nodeserver:1.0.0
container_name: nodeapp
restart: unless-stopped
volumes:
  - /data/usersFolder:/server/config
ports:
  - "3000:3000"
networks:
  - app-network

nginx:

image: nginx:1.15-alpine
container_name: nginx_server
restart: unless-stopped
volumes:
  - ./data/nginx:/etwww.pizei.comc/nginx/conf.d
  - ./data/certbot/conf:/etc/letsencrypt
  - ./data/certbot/www:/var/www/certbot
ports:
  - "80:80"
  - "443:443"
networks:
  - app-network
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''

certbot:

image: certbot/certbot
restart: unless-stopped
container_name: certbot_one
volumes:
  - ./data/certbot/conf:/etc/letsencrypt
  - ./data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

networks:
app-network:

driver: bridge

By creating a network to let nginx communicate directly with the node server, the conf of nginx can also be written smoothly. In the past, I remember that – link can be used for inter container communication, but the official recommended practice is to create a network

Recommended Today

You have to know about JVM garbage collection

catalogue 1、 Four citation methods1.1 strong reference1.2 soft reference1.3 weak reference1.4 phantom reference 2、 How to judge whether the object is garbage2.1 reference counting method2.2 root accessibility analysis 3、 Garbage collection algorithm3.1 mark sweep3.2 mark compact3.3 mark copy 4、 Garbage collector4.1 classification and characteristics4.1.1 serial4.1.2 throughput priority4.1.3 priority of response time4.2 serial garbage collector details […]