repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

Antonio Mika  ·  2025-02-12

dev.md

 1## development
 2
 3- `golang` >= 1.24
 4- `direnv` to load environment vars
 5
 6```bash
 7cp ./.env.example .env
 8```
 9
10If you are running apps outside of docker, remember to change the postgres, minio, and imgproxy hostnames to "localhost" in `.env`.
11
12Initialize local env variables using direnv
13
14```bash
15echo dotenv > .envrc && direnv allow
16```
17
18Boot up database (or bring your own)
19
20```bash
21docker compose -f docker-compose.yml -f docker-compose.override.yml --profile db up -d
22```
23
24Create db and migrate
25
26```bash
27make create
28make migrate
29```
30
31```bash
32go run ./cmd/pgs/ssh
33# in a separate terminal
34go run ./cmd/pgs/web
35```
36
37## sign up and upload files
38
39The initial database has no users, you need to sign up via pico/ssh:
40
41```bash
42go run ./cmd/pico/ssh
43# in a separate terminal, complete the signup flow, set your username to "picouser"
44ssh localhost -p 2222
45```
46
47Stop the pico SSH server, then you can upload files:
48
49```bash
50go run ./cmd/pgs/ssh
51# in a separate terminal
52go run ./cmd/pgs/web
53# in a third terminal
54echo 'Hello, World!' > file.txt
55scp -P 2222 file.txt localhost:/test/file.txt
56curl -iH "Host: picouser-test.pgs.dev.pico.sh" localhost:3000/file.txt
57```
58
59## deployment
60
61We use an image based deployment, so all of our images are uploaded to
62[ghcr.io/picosh/pico](https://github.com/picosh/pico/packages)
63
64```bash
65DOCKER_TAG=latest make bp-all
66```
67
68Once images are built, docker compose is used to stand up the services:
69
70```bash
71docker compose up -d
72```
73
74This makes use of a production `.env.prod` environment file which defines the
75various listening addresses and services that will be started. For production,
76we add a `.envrc` containing the following:
77
78```bash
79export COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml
80export COMPOSE_PROFILES=services,caddy
81```
82
83And symlink `.env` to `.env.prod`:
84
85```bash
86ln -s .env.prod .env
87```
88
89This allows us to use docker-compose normally as we would in development.
90
91For any migrations, logging into the our database server, pulling the changes to
92migrations and running `make latest` is all that is needed.