# Run Activepieces - Open Source Business Automation - In Docker

## What is Activepieces?

> [Activepieces is an open-source] alternative to Zapier. Automate your work for free and without writing code, keep your data on your machine. -https://github.com/activepieces/activepieces

## Installing Docker

1. Log into the Linux based device
2. Run the following commands in the terminal
   # install prerequisites
   sudo apt install apt-transport-https ca-certificates git curl software-properties-common gnupg-agent -y
   # add docker gpg key
   curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
   # add docker software repository
   sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
   # install docker
   sudo apt install docker-ce docker-compose containerd.io -y
   # enable and start docker service
   sudo systemctl enable docker && sudo systemctl start docker
   # add the current user to the docker group
   sudo usermod -aG docker $USER
   # reauthenticate for the new group membership to take effect
   su - $USER

## Building Activepieces from Source

1. Continue with the following commands in a terminal window
   # create working directories
   mkdir ~/docker/activepieces -p && mkdir ~/docker/postgresql -p && mkdir ~/docker/redis -p
   # clone source code from github
   git clone https://github.com/activepieces/activepieces.git ~/docker/activepieces
   # change directory
   cd ~/docker/activepieces
   # create .env
   sh tools/deploy.sh
   # edit .env
   sudo nano .env
2. Edit the following fields in the .env file

   AP_FRONTEND_URL=http://<%DNSorIP%>:8990
   AP_POSTGRES_DATABASE=active_pieces
   AP_POSTGRES_HOST=<%Docker Host DNSorIP%>
   AP_POSTGRES_PORT=5432
   AP_POSTGRES_USERNAME=active_pieces_rw
   AP_POSTGRES_PASSWORD=Act1veP1EcES!
   AP_REDIS_HOST=<%Docker Host DNSorIP%>
   AP_REDIS_PORT=6379
   AP_TELEMETRY_ENABLED=false

3. Press CTRL+O, Enter, CTRL+X to write the changes and exit
4. Continue with the following commands in the terminal
   # build the activepieces image
   docker buildx build -t local/activepieces:latest .
5. The build process will take several minutes to complete

## Running Activepieces

1. Continue following commands in a terminal window
   # note the sha256 in the build output, the first 12 characters can be used to interact with the new image
   # list available images
   docker image ls
   # run the postgesql container
   docker run -d --name postgres -e POSTGRES_USER=active_pieces_rw -e POSTGRES_PASSWORD=Act1veP1EcES! -e POSTGRES_DB=active_pieces -e POSTGRES_INITDB_ARGS="--encoding=UTF-8" --network host -v ~/docker/postgresql:/var/lib/postgresql/data --restart=unless-stopped postgres:latest
   # run the redis container
   docker run -d --name redis -v ~/docker/redis:/data --network host --restart=unless-stopped redis
   # run activepieces container
   # --dns is optional if using IP addresses instead of DNS names in .env
   docker run -d --name=activepieces --env-file ~/docker/activepieces/.env --dns="192.168.0.1" -p 8990:80 --restart=unless-stopped local/activepieces
2. Open a web browser and navigate to http://DNSorIP:8990
3. Enter a first name, last name, email address and password > Click Sign up
4. Welcome to Activepieces

Documentation: https://www.activepieces.com/docs/install/docker