Skip to content

Commit

Permalink
Docker镜像添加前端的部署;
Browse files Browse the repository at this point in the history
  • Loading branch information
cxOrz committed Mar 8, 2023
1 parent 0dbb23d commit acfa01f
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# syntax=docker/dockerfile:1

FROM node:lts-alpine
FROM alpine:latest

WORKDIR /app

COPY . .

RUN apk add --no-cache libc6-compat && corepack enable && pnpm install && pnpm build
RUN apk add --no-cache libc6-compat nodejs-current nginx && corepack enable && pnpm install && pnpm build && cp -f nginx.conf /etc/nginx

EXPOSE 5000
EXPOSE 5000 80

CMD [ "node", "apps/server/build/serve.js" ]
CMD nginx && echo 'Nginx: http://localhost:80' && node apps/server/build/serve.js
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)
![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white)
![Licence](https://img.shields.io/github/license/cxOrz/chaoxing-sign-cli?style=for-the-badge)

基于 Nodejs 实现的一个命令行签到工具,在此基础上使用 React.js + Material UI + Koa 扩展成为 Web 项目。
Expand All @@ -14,7 +15,7 @@

安卓手机上可以用 Termux 来运行NodeJS程序,[查看Termux教程](./apps/server/src/docs/termux.md)

苹果手机请查看 [高级](#高级-🎲) 部分,通过这种方式来使用,当然这种方式也适用于其他。
苹果手机请查看 [高级](#高级-) 部分,通过这种方式来使用,当然这种方式也适用于其他。

## 部署 🛠

Expand Down Expand Up @@ -93,12 +94,21 @@ pnpm start

除了简单的 `pnpm start` 来手动签到,也可以部署到服务器使用网页版本,别忘了这也是个 Web 项目。

- 前端界面,查看 [前端](/apps/web) 的部署方式
- 后端服务,查看 [服务端](/apps/server) 的部署方式
- 前端界面,查看 [前端](/apps/web) 的说明
- 后端服务,查看 [服务端](/apps/server) 的说明

### 一键运行

根目录下执行 `pnpm dev` 将运行前后端服务,并在浏览器弹出项目首页,注意这是开发模式!
方案一:根目录下执行 `pnpm dev` 将运行前后端服务,并在浏览器弹出项目首页,注意这是开发模式!

方案二:用提供的 Docker 镜像,运行后可通过 IP 访问。

```bash
docker pull ghcr.io/cxorz/chaoxing-sign-cli:latest
docker run -d -p 80:80 -p 5000:5000 chaoxing-sign-cli
```

> 出现问题?先仔细阅读相关说明,若仍无法解决请发 issue
### 展示

Expand Down
110 changes: 110 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# /etc/nginx/nginx.conf

user nginx;

# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;

# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;

# Configures default error logger.
error_log /var/log/nginx/error.log warn;

# Includes files with directives to load dynamic modules.
include /etc/nginx/modules/*.conf;

# Include files with config snippets into the root context.
include /etc/nginx/conf.d/*.conf;

events {
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 1024;
}

http {
# Includes mapping of file name extensions to MIME types of responses
# and defines the default type.
include /etc/nginx/mime.types;
default_type application/octet-stream;

# Name servers used to resolve names of upstream servers into addresses.
# It's also needed when using tcpsocket and udpsocket in Lua modules.
#resolver 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001;

# Don't tell nginx version to the clients. Default is 'on'.
server_tokens off;

# Specifies the maximum accepted body size of a client request, as
# indicated by the request header Content-Length. If the stated content
# length is greater than this size, then the client receives the HTTP
# error code 413. Set to 0 to disable. Default is '1m'.
client_max_body_size 1m;

# Sendfile copies data between one FD and other from within the kernel,
# which is more efficient than read() + write(). Default is off.
sendfile on;

# Causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames. Default is 'off'.
tcp_nopush on;


# Enables the specified protocols. Default is TLSv1 TLSv1.1 TLSv1.2.
# TIP: If you're not obligated to support ancient clients, remove TLSv1.1.
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

# Path of the file with Diffie-Hellman parameters for EDH ciphers.
# TIP: Generate with: `openssl dhparam -out /etc/ssl/nginx/dh2048.pem 2048`
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;

# Specifies that our cipher suits should be preferred over client ciphers.
# Default is 'off'.
ssl_prefer_server_ciphers on;

# Enables a shared SSL cache with size that can hold around 8000 sessions.
# Default is 'none'.
ssl_session_cache shared:SSL:2m;

# Specifies a time during which a client may reuse the session parameters.
# Default is '5m'.
ssl_session_timeout 5m;

# Disable TLS session tickets (they are insecure). Default is 'on'.
ssl_session_tickets off;


# Enable gzipping of responses.
gzip on;

# Set the Vary HTTP header as defined in the RFC 2616. Default is 'off'.
gzip_vary on;


# Helper variable for proxying websockets.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}


# Specifies the main log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

# Sets the path, format, and configuration for a buffered log write.
access_log /var/log/nginx/access.log main;

server {
listen 80;
server_name localhost;

location / {
root /app/apps/web/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chaoxing-sign",
"version": "4.1.0",
"version": "4.1.3",
"description": "超星学习通签到项目",
"workspaces": [
"apps/*",
Expand Down

0 comments on commit acfa01f

Please sign in to comment.