文章名《从零玩转系列之腾讯云扫码授权系统-前端PC篇》 作者:杨不易呀
评价:
本文详细介绍了使用Vue3构建PC端扫码登录系统的全过程,从环境准备到功能实现,步骤清晰,非常适合前端新手学习。文章不仅提供了必要的代码示例,还附有视频讲解,帮助读者更好地理解和实践。
文章链接:https://cloud.tencent.com/developer/article/2472491
Szurubooru
提供了一个强大而灵活的平台,让社区成员可以上传、分享、讨论以及管理多媒体内容。它支持多种媒体格式,并提供了一系列工具来帮助用户组织和发现内容。该平台特别适合那些需要高度定制化和控制自己内容存储与展示方式的小众爱好者群体。
本次实践为个人测试环境,操作系统版本为|Ubuntu 22.04.1。
hostname | IP地址 | 操作系统版本 | 内核版本 | Docker版本 | 镜像版本 |
---|---|---|---|---|---|
jeven01 | 192.168.3.88 | Ubuntu 22.04.1 LTS | 5.15.0-119-generic | 24.0.7 | 2.5 |
1.本次实践部署环境为个人测试环境,生产环境请谨慎;
2.在Docker环境下部署Szurubooru图像板应用。
检查Docker服务是否正常运行,确保Docker正常运行。
root@ubuntu-001:~# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2024-09-29 08:29:36 UTC; 18min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 5227 (dockerd)
Tasks: 123
Memory: 272.5M
CPU: 9.692s
CGroup: /system.slice/docker.service
├─5227 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
检查Docker版本
root@ubuntu-001:~# docker -v
Docker version 24.0.7, build 24.0.7-0ubuntu2~22.04.1
检查Docker compose版本,确保2.0以上版本。
root@ubuntu-001:~# docker compose version
Docker Compose version v2.19.1
拉取Szurubooru镜像,其中镜像szurubooru两个镜像版本使用的为2.5。
docker pull szurubooru/server:2.5
docker pull szurubooru/client:2.5
docker pull postgres:11-alpine
mkdir -p /data/szurubooru && cd /data/szurubooru
chmod -R 777 /data/szurubooru/
编辑config.yaml配置文件,内容所辖:
vim config.yaml
# rather than editing this file, it is strongly suggested to create config.yaml
# and override only what you need.
# shown in the website title and on the front page
name: szurubooru
# full url to the homepage of this szurubooru site, with no trailing slash
domain: # example: http://example.com
# used to salt the users' password hashes and generate filenames for static content
secret: change
# Delete thumbnails and source files on post delete
# Original functionality is no, to mitigate the impacts of admins going
# on unchecked post purges.
delete_source_files: no
thumbnails:
avatar_width: 300
avatar_height: 300
post_width: 300
post_height: 300
# settings used to download files from the web on behalf of the api users
user_agent:
max_dl_filesize: 25.0E+6 # maximum filesize limit in bytes
# automatically convert animated GIF uploads to video formats
convert:
gif:
to_webm: false
to_mp4: false
# allow posts to be uploaded even if some image processing errors occur
allow_broken_uploads: false
# used to send password reset e-mails
smtp:
host: # example: localhost
port: # example: 25
user: # example: bot
pass: # example: groovy123
from: # example: noreply@example.com
# if host is left empty the password reset feature will be disabled,
# in which case it is recommended to fill contactEmail so that users
# know who to contact when they want to reset their password
contact_email: # example: bob@example.com. Meant for manual password reset procedures
enable_safety: yes
tag_name_regex: ^\S+$
tag_category_name_regex: ^[^\s%+#/]+$
pool_name_regex: ^\S+$
pool_category_name_regex: ^[^\s%+#/]+$
# don't make these more restrictive unless you want to annoy people; if you do
# customize them, make sure to update the instructions in the registration form
# template as well.
password_regex: '^.{5,}$'
user_name_regex: '^[a-zA-Z0-9_-]{1,32}$'
# webhooks to call when events occur (such as post/tag/user/etc. changes)
# the listed urls will be called with a HTTP POST request with a payload
# containing a snapshot resource as JSON. See doc/API.md for details
webhooks:
# - https://api.example.com/webhooks/
default_rank: regular
privileges:
'users:create:self': anonymous # Registration permission
'users:create:any': administrator
'users:list': regular
'users:view': regular
'users:edit:any:name': moderator
'users:edit:any:pass': moderator
'users:edit:any:email': moderator
'users:edit:any:avatar': moderator
'users:edit:any:rank': moderator
'users:edit:self:name': regular
'users:edit:self:pass': regular
'users:edit:self:email': regular
'users:edit:self:avatar': regular
'users:edit:self:rank': moderator # one can't promote themselves or anyone to upper rank than their own.
'users:delete:any': administrator
'users:delete:self': regular
'user_tokens:list:any': administrator
'user_tokens:list:self': regular
'user_tokens:create:any': administrator
'user_tokens:create:self': regular
'user_tokens:edit:any': administrator
'user_tokens:edit:self': regular
'user_tokens:delete:any': administrator
'user_tokens:delete:self': regular
'posts:create:anonymous': regular
'posts:create:identified': regular
'posts:list': anonymous
'posts:reverse_search': regular
'posts:view': anonymous
'posts:view:featured': anonymous
'posts:edit:content': power
'posts:edit:flags': regular
'posts:edit:notes': regular
'posts:edit:relations': regular
'posts:edit:safety': power
'posts:edit:source': regular
'posts:edit:tags': regular
'posts:edit:thumbnail': power
'posts:feature': moderator
'posts:delete': moderator
'posts:score': regular
'posts:merge': moderator
'posts:favorite': regular
'posts:bulk-edit:tags': power
'posts:bulk-edit:safety': power
'posts:bulk-edit:delete': power
'tags:create': regular
'tags:edit:names': power
'tags:edit:category': power
'tags:edit:description': power
'tags:edit:implications': power
'tags:edit:suggestions': power
'tags:list': regular
'tags:view': anonymous
'tags:merge': moderator
'tags:delete': moderator
'tag_categories:create': moderator
'tag_categories:edit:name': moderator
'tag_categories:edit:color': moderator
'tag_categories:edit:order': moderator
'tag_categories:list': anonymous
'tag_categories:view': anonymous
'tag_categories:delete': moderator
'tag_categories:set_default': moderator
'pools:create': regular
'pools:edit:names': power
'pools:edit:category': power
'pools:edit:description': power
'pools:edit:posts': power
'pools:list': regular
'pools:view': anonymous
'pools:merge': moderator
'pools:delete': moderator
'pool_categories:create': moderator
'pool_categories:edit:name': moderator
'pool_categories:edit:color': moderator
'pool_categories:list': anonymous
'pool_categories:view': anonymous
'pool_categories:delete': moderator
'pool_categories:set_default': moderator
'comments:create': regular
'comments:delete:any': moderator
'comments:delete:own': regular
'comments:edit:any': moderator
'comments:edit:own': regular
'comments:list': regular
'comments:view': regular
'comments:score': regular
'snapshots:list': power
'uploads:create': regular
'uploads:use_downloader': power
## ONLY SET THESE IF DEPLOYING OUTSIDE OF DOCKER
#debug: 0 # generate server logs?
#show_sql: 0 # show sql in server logs?
#data_url: /data/
#data_dir: /var/www/data
## usage: schema://user:password@host:port/database_name
## example: postgres://szuru:dog@localhost:5432/szuru_test
#database:
在部署目录下,新建及编辑.env文件
vim .env
# Database credentials
POSTGRES_USER=jeven
POSTGRES_PASSWORD=jeven
# This shows up on the homescreen, indicating build information
BUILD_INFO=latest
# Port to expose HTTP service
# Set to 127.0.0.1:8080 if you wish to reverse-proxy the docker's port,
# otherwise the port specified here will be publicly accessible
PORT=8080
# How many waitress threads to start
# 4 is the default amount of threads. If you experience performance
# degradation with a large number of posts, increasing this may
# improve performance, since waitress is most likely clogging up with Tasks.
THREADS=4
# URL base to run szurubooru under
# See "Additional Features" section in INSTALL.md
BASE_URL=/
# Directory to store image data
MOUNT_DATA=/data/szurubooru/data
# Directory to store database files
MOUNT_SQL=/data/szurubooru/sql
在/data/szurubooru`目录下,创建docker-compose.yaml文件,宿主机映射端口可自行修改,注意防止端口冲突。
vim docker-compose.yaml
## Example Docker Compose configuration
##
## Use this as a template to set up docker-compose, or as guide to set up other
## orchestration services
version: '2'
services:
server:
image: szurubooru/server:2.5
depends_on:
- sql
environment:
## These should be the names of the dependent containers listed below,
## or FQDNs/IP addresses if these services are running outside of Docker
POSTGRES_HOST: sql
## Credentials for database:
POSTGRES_USER:
POSTGRES_PASSWORD:
## Commented Values are Default:
#POSTGRES_DB: defaults to same as POSTGRES_USER
#POSTGRES_PORT: 5432
#LOG_SQL: 0 (1 for verbose SQL logs)
THREADS:
volumes:
- "${MOUNT_DATA}:/data"
- "./config.yaml:/opt/app/config.yaml"
client:
image: szurubooru/client:2.5
depends_on:
- server
environment:
BACKEND_HOST: server
BASE_URL:
volumes:
- "${MOUNT_DATA}:/data:ro"
ports:
- "${PORT}:80"
sql:
image: postgres:11-alpine
restart: unless-stopped
environment:
POSTGRES_USER:
POSTGRES_PASSWORD:
volumes:
- "${MOUNT_SQL}:/var/lib/postgresql/data"
执行以下命令,创建Szurubooru容器。
root@jeven01:/data/szurubooru# docker compose up -d
[+] Running 4/4
✔ Network szurubooru_default Created 0.1s
✔ Container szurubooru-sql-1 Started 0.4s
✔ Container szurubooru-server-1 Started 0.6s
✔ Container szurubooru-client-1 Started 0.8s
检查Szurubooru容器状态状态,确保Szurubooru容器正常启动。
root@jeven01:/data/szurubooru# docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
szurubooru-client-1 szurubooru/client:2.5 "/docker-entrypoint.…" client 36 seconds ago Up 35 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp
szurubooru-server-1 szurubooru/server:2.5 "/opt/app/docker-sta…" server 36 seconds ago Up 35 seconds 6666/tcp
szurubooru-sql-1 postgres:11-alpine "docker-entrypoint.s…" sql 37 seconds ago Up 36 seconds 5432/tcp
检查Szurubooru容器日志,确保Szurubooru服务正常运行。
root@jeven01:/data/szurubooru# docker compose logs
szurubooru-sql-1 |
szurubooru-sql-1 |
szurubooru-sql-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
szurubooru-sql-1 |
szurubooru-sql-1 |
szurubooru-sql-1 | 2024-10-03 10:19:51.218 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
szurubooru-sql-1 | 2024-10-03 10:19:51.218 UTC [1] LOG: listening on IPv6 address "::", port 5432
szurubooru-sql-1 | 2024-10-03 10:19:51.221 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
szurubooru-sql-1 | 2024-10-03 10:19:51.235 UTC [22] LOG: database system was shut down at 2024-10-03 10:19:27 UTC
szurubooru-sql-1 | 2024-10-03 10:19:51.242 UTC [1] LOG: database system is ready to accept connections
szurubooru-server-1 | INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
szurubooru-server-1 | INFO [alembic.runtime.migration] Will assume transactional DDL.
szurubooru-server-1 | Starting szurubooru API on port 6666 - Running on 4 threads
访问地址:http://192.168.3.88:8080,将IP替换为自己服务器IP地址。如果无法访问到以下页面,则检查宿主机的防火墙是否关闭或者放行相关端口,云服务器则还需要设置安全组规则。
入下图所示,在菜单栏点击“
Register
”选项,注册账号。
自定义填写账号相关信息,确认注册即可。
在本次Docker项目实战中,我们成功运用Docker容器化技术部署了Szurubooru图像板应用,不仅实现了快速搭建和环境隔离,还显著提升了工作效率。通过Docker进行部署极大缩短了准备时间,同时保证了Szurubooru能够在多种环境中稳定运行。这一过程简化了应用的配置与管理,为开发者提供了极大的便利。鉴于其简便性和实用性,推荐对图像板感兴趣的朋友尝试使用Docker来部署Szurubooru。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。