You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.0 KiB

phCD

Continuous Deployment for PHC projects.

Development

# First install the dependencies
$ pnpm install

# Run the local server
$ pnpm dev

# Build all
$ pnpm build

Bootstrapping

Run the following command to bootstrap a phCD instance. As this service doesn't have auth for now, it's strongly recommended to publish only on a local ip like 127.0.0.1 and then access directly or via an ssh tunnel (something like ssh -L 8080:127.0.0.1:8080 server).

# Clone this repo
$ git clone https://git.phc.dm.unipi.it/phc/phcd

# Create config files and data folder
$ mkdir data.local
$ cp .env.sample .env
$ echo 'deploys: []' > config.yaml

# Built docker image
$ docker built . -t phcd

# Start container
$ docker run -d \
  --name phcd \
  --restart unless-stopped \
  -p 127.0.0.1:8080:4321 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v ./data.local:/app/data.local \
  -v ./.env:/app/.env \
  -v ./config.yaml:/app/config.yaml \
  phcd

Updating

$ git pull

$ docker stop phcd
$ docker built . -t phcd
$ docker run -d \
  --name phcd \
  --restart unless-stopped \
  -p 127.0.0.1:8080:4321 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v ./data.local:/app/data.local \
  -v ./config.yaml:/app/config.yaml \
  phcd

Architecture

Everything is stored in the config.yaml file. This file contains a list of projects to deploy and the configuration for each one.

deploys:
  - name: project1
    url: https://github.com/username/project1
    ref: 
      type: branch
      value: main
    type: dockerfile
    options:
      ports: 
        - 80:8080
      volumes: 
        - /var/www/html:/var/www/html
  - name: project2
    url: ssh://example.org/username/project2.git
    ref:
      type: commit
      value: '1234567'
    type: docker-compose
    options:
      path: ./docker-compose.yml # already the default
  - name: project3
    url: https://github.com/username/project3
    type: shell
    options:
      path: ./deploy.sh # already the default