This project intends to be the go implementation of ptt/pttbbs.
Collaborating with Ptt-official-app pttbbs-backend, go-pttbbs intends to be web-based bbs.
You can start with the following steps:
cd docs; tar -zxvf bbs-2025-03-22.tar.gz; cd ..docker-compose --env-file docker/go-pttbbs/docker_compose.examples.env -f docker/go-pttbbs/docker-compose.yaml up -dcurl -i -H 'X-Forwarded-For: 127.0.0.1' 'http://localhost:3456/v1/board/WhoAmI/articles?max=5&desc=true'
You can start with the swagger api and check the api document.
You can do the following to start with docker-compose:
- copy
docs/etc/to someetcdirectory (ex:/etc/go-pttbbs). - copy
docs/config/01-config.docker.inito theetcdirectory asproduction.ini(ex:cp docs/config/01-config.docker.ini /etc/go-pttbbs/production.ini). - copy
docker/go-pttbbs/docker_compose.tmpl.envtodocker/go-pttbbs/docker_compose.envand modify the settings. docker-compose --env-file docker/go-pttbbs/docker_compose.env -f docker/go-pttbbs/docker-compose.yaml up -d
./scripts/test.sh./scripts/coverage.shYou can do the following to execute ./scripts/run.sh:
cd docs; tar -zxvf bbs-2025-03-22.tar.gz; cd .../scripts/run-dev.shcurl -i -H 'X-Forwarded-For: 127.0.0.1' 'http://localhost:3456/v1/board/WhoAmI/articles?max=5&desc=true'
Some config-variables are required const in ptttype, to be defined as Cstr (IDLEN, PASSLEN, etc.)
For the normal config-variables, we use config.ini as the configuration.
For the const config-variables in ptttype, We use docs/config/00-config-[dev-mode].go with +build flag
We use viper and .ini as our config-framework.
docs/config/config.tmpl.ini is the config-template file.
We have 3 files For every module with the config:
00-config.go: define the variables of the config.config.go: define the func of setting the variables from the config-file.config_util.go: helper functions. should be straightforward to follow.
We can customized ptttype/00-config-default.go with the following steps:
- copy
docs/config/config-dev.gotoptttype/00-config-[dev-mode].goand change the+buildand variables accordingly. go build -tag [dev-mode]
The swagger setup is based on flask-swagger, which is a python-project. You can do following for the swagger-api:
- setup the python virtualenv.
- cd apidoc; pip install -e . ; cd ..
- ./scripts/swagger.sh
- browse to http://localhost:8081.
Some parts of the Dockerfile are adopted from bbsdocker/imageptt, Copyright © 2018-2020 holishing, Licensed under MIT License.