Private as in the content is not public by default and discovery requires a human touch. Please refer to manifesto for more details.
Pcom uses gogo to handle forms and some other things!
If you want to follow the development, there is a youtube playlist with demos!
Official client is blg, command line client that plays well with pcom. See docs/api.md for the API.
- Go (version from
go.mod) - Node.js (version from
.tool-versions) and yarn - PostgreSQL
- libvips (
brew install vips pkg-config) - Docker, for the test suite (tests start their own Postgres container)
envsubst(brew install gettext), used by./generate.sh
- Install go, asdf, postgres, watchexec
asdf install(installs node)npm install -g yarncd cmd/web; yarn installgo install github.com/rubenv/sql-migrate/sql-migrate@latestgo install github.com/volatiletech/sqlboiler/v4@latestgo install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latestcreateuser pcom -Wusepcomas a password therecreatedb --owner=pcom pcom_devecho 'SESSION_SALT=random' >> cmd/web/.envecho 'SITE_ROOT=http://localhost:8080' >> cmd/web/.envecho 'DATABASE_URL=postgres://pcom:pcom@localhost:5432/pcom_dev?sslmode=disable' >> cmd/web/.env./sqlmigrate.sh up
The server listens on $PORT, 8080 by default, so SITE_ROOT has to match it.
Registration is controlled by system_settings.registration_open. For local
development you can bypass it with go run . -force-signup.
cd cmd/web
yarn watch # in one tab: rebuilds frontend assets into cmd/web/dist
make watchexec # in another tab: restarts the server on changes
The server needs cmd/web/dist/manifest.json to exist, so run yarn watch
(or yarn build) at least once before starting it.
make check # build + all tests, no artifacts
make test # tests only
make lint # golangci-lint
Docker must be running: tests that touch the database start a Postgres
container via testcontainers/postgres.
psql -U pcom pcom_dev
./sqlmigrate.sh new migration_name
Edit the file given by sql-migrate
./sqlmigrate.sh up
./generate.sh
./generate.sh regenerates the sqlboiler models in pkg/model/core from the
database in cmd/web/.env.
-
change remote and push to the new repo
-
change flytoml to point to the new app pcom
-
create the app on fly
flyctl apps create pcom -
create db, set 4gb ram
fly postgres create -n pcomdb -
attach db to the app
flyctl postgres attach -a pcom pcomdb -
Set secrets:
flyctl secrets set SESSION_SALT=<random string> flyctl secrets set SITE_ROOT=https://pcom.com flyctl secrets set MJ_APIKEY_PUBLIC=<public key from mailjet> flyctl secrets set MJ_APIKEY_PRIVATE=<private key from mailjet> # this one should include scheme flyctl secrets set USER_MEDIA_ENDPOINT=<endpoint> flyctl secrets set USER_MEDIA_BUCKET=<bucket> flyctl secrets set USER_MEDIA_KEY=<key> flyctl secrets set USER_MEDIA_REGION=<region> flyctl secrets set USER_MEDIA_SECRET=<secret> flyctl secrets set SENDER_ADDRESS=<address> flyctl secrets set ADMIN_ADDRESS=<address> flyctl secrets set STATIC_CDN=<address> # in case you want to put static resources behind the cdn flyctl secrets set USER_MEDIA_CDN=<address> # in case you want to put user images behind the cdn flyctl secrets set ENABLE_PPROF=true # optional, serves pprof on :8081 (see `make pprof_tunnel`)The app switches to production behavior (mailjet sender, S3 storage, secure cookies, HSTS) when
FLY_APP_NAMEis set, which fly does automatically. -
Do first deploy
fly deploy, make sure you can reach the app via .fly.dev -
Create a cert for your custom domain
fly certs add pcom.com -
After it screams at you, add required A and AAAA records
-
You might need to run
fly certs check pcom.coma couple of times,fly certs listshould show your domain with the statusready. -
You should be able to reach your app via custom domain at this point
-
Go to mailjet and add new domain
-
Add sender email address there
-
Add required txt record to validate domain
-
Add required txt records to add DKIM and SPF settings
-
Run the following from the project root to get the database schema in place
Tab 1:
fly proxy 5433:5432 -a pcomdb # or: make tunnel
Tab 2:
./run.sh # opens a shell with the production secrets loaded
./sqlmigrate.sh up
run.sh evaluates ./env.pl, which reads the app's secrets from fly and
rewrites DATABASE_URL to point at the proxied localhost:5433. Don't redirect
./env.pl into cmd/web/.env, because that would overwrite your local
development settings with production ones.
-
App instance is running in a wrong dc:
fly scale count 0 fly scale count 1 --region ams
Work to add test coverage and then modernize the codebase is planned in docs/implementation-plan.md.
The project has been generated by gogo-cli and uses gogo library