Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose support #111

Merged
merged 54 commits into from
Jun 2, 2024
Merged

Conversation

Siumauricio
Copy link
Contributor

@Siumauricio Siumauricio commented May 29, 2024

Close #17 #73 #56

Implement docker compose deployments using Docker Compose or Docker Stack Deploy

To try out this feature you can use curl -sSL https://dokploy.com/feature.sh | sh

Compose feature

Currently we have 3 different types of deployments:

  • Application
  • Database
  • Compose (New):
    1. Deploy via github
    2. Deploy via git
    3. Raw ( Means you paste a docker compose file and it will run )
      1. We include a random docker composition, which serves to prevent conflicts with existing services, thus saving you time by adding a prefix to each service, volume and so on.

We provide two options when creating a docker compose, the first is using docker compose, the second one is docker stack

The docker compose works in any cases, but using the docker stack deploy is for specifically use the same compose file but with less features and more focus on orchrestation (Docker Swarm)

Blog: https://vsupalov.com/difference-docker-compose-and-docker-stack/

How to test?

To test the complexity of Docker Compose, I deploy a Directus application based on the documentation. Here is the compose file: https://docs.directus.io/self-hosted/docker-guide.html#example-docker-compose

What's the difference between the link and the file below? Nothing. To make the application accessible via a domain, simply create a DNS record and add it to the labels, specifically in the Host rule.

We don't add anything to the docker compose so if you have a compose file it should work the same as in your machine.

When you deploy go to directus.dokploy.com this is in my case, make sure to update to your domain name

version: '3'
services:
  database-c42cea9b:
    image: postgis/postgis:13-master
    volumes:
      - directus-db-c42cea9b:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: directus
      POSTGRES_PASSWORD: directus
      POSTGRES_DB: directus
    networks:
      - dokploy-network
  cache-c42cea9b:
    image: redis:6
    networks:
      - dokploy-network
  directus-c42cea9b:
    image: directus/directus:10.10.5
    ports:
      - '8055'
    volumes:
      - ./uploads:/directus/uploads
      - ./extensions:/directus/extensions
    depends_on:
      - cache-c42cea9b
      - database-c42cea9b
    environment:
      KEY: 255d861b-5ea1-5996-9aa3-922530ec40b1
      SECRET: 6116487b-cda1-52c2-b5b5-c8022c45e263
      DB_CLIENT: pg
      DB_HOST: database
      DB_PORT: '5432'
      DB_DATABASE: directus
      DB_USER: directus
      DB_PASSWORD: directus
      CACHE_ENABLED: 'true'
      CACHE_STORE: redis
      REDIS: redis://cache:6379
      ADMIN_EMAIL: admin@example.com
      ADMIN_PASSWORD: d1r3ctu5
    labels:
      - traefik.enable=true
      - traefik.http.routers.directus-2.rule=Host(`directus.dokploy.com`)
      - traefik.http.routers.directus-2.entrypoints=websecure
      - traefik.http.routers.directus-2.tls.certResolver=letsencrypt
      - traefik.http.services.directus-2.loadbalancer.server.port=8055
    networks:
      - dokploy-network
volumes:
  directus-db-c42cea9b: null
networks:
  dokploy-network:
    external: true

Screenshot 2024-05-29 at 12 25 38 AM

Another example deploying the official plausible repository via github

Screen.Recording.2024-05-29.at.12.44.49.AM.mp4

Pocketbase deployment in a single file

version: "3.7"
services:
  pocketbase:
    image: spectado/pocketbase:latest
    restart: unless-stopped
    ports:
      - "80"
    networks:
      - dokploy-network
    labels:
      - traefik.enable=true
      - traefik.http.routers.directus-2.rule=Host(`test2.dokploy.com`)
      - traefik.http.routers.directus-2.entrypoints=websecure
      - traefik.http.routers.directus-2.tls.certResolver=letsencrypt
      - traefik.http.services.directus-2.loadbalancer.server.port=80
    volumes:
      - /etc/dokploy/data:/pb_data
      - /etc/dokploy/public:/pb_public
      - /etc/dokploy/migrations:/pb_migrations

networks:
  dokploy-network:
    external: true

Screenshot 2024-05-29 at 9 36 22 PM
Screenshot 2024-05-29 at 9 36 43 PM

@DontFred
Copy link
Contributor

Super!

@Rattlyy
Copy link

Rattlyy commented Jun 1, 2024

arm64 build?

@Siumauricio
Copy link
Contributor Author

@Rattlyy Please try now, i pushed a new version including arm build

@Siumauricio Siumauricio merged commit 8f9d21c into canary Jun 2, 2024
2 checks passed
@Siumauricio Siumauricio deleted the 17-create-application-with-docker-compose branch June 2, 2024 21:26
Siumauricio added a commit that referenced this pull request Jun 3, 2024
* feat: add schema for registry and routes

* feat: add docker registry upload

* feat: add show cluster

* refactor: set the registry url in image in case we have a registry asociated

* feat: add update registry and fix the docker url markup

* chore: remove --advertise-ip on swarm script

* refactor: remove listen address of swarm initialize

* feat: add table to show nodes and add dropdown to add manager & workers

* refactor: improve interface for cluster

* refactor: improve UI

* feat: add experimental swarm settings

* refactor: remove comments

* refactor: prettify json of each setting

* refactor: add interface tooltip

* refactor: delete static form self registry

* refactor: allow to se a empty registry

* fix: remove text area warnings

* feat: add network swarm json

* refactor: update ui

* revert: go back to swarm init config

* refactor: remove initialization on server, only on setup script

* Update LICENSE.MD

* feat: appearance theme support system config

* refactor: remove logs

* fix(README-ru): hyperlink-ed docs url

* feat: (#107) webhook listener filter docker events based on image tag.

Fixes #107

* refactor: simplify comparison docker tags

* refactor: remove return in res status

* refactor: prevent to updates download automatically

* feat: support code editor (#105)

* feat: support code editor

* Update codeblock

* refactor: remove unused class

---------

Co-authored-by: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>

* fix: select the right image from sourcetype (#109)

* chore: bump minor version

* fix: add redirect to https by default (#113)

* Create FUNDING.yml

* Docker compose support (#111)

* feat(WIP): compose implementation

* feat: add volumes, networks, services name hash generate

* feat: add compose config test unique

* feat: add tests for each unique config

* feat: implement lodash for docker compose parsing

* feat: add tests for generating compose file

* refactor: implement logs docker compose

* refactor: composeFile set not empty

* feat: implement providers for compose deployments

* feat: add Files volumes to compose

* feat: add stop compose button

* refactor: change strategie of building compose

* feat: create .env file in composepath

* refactor: simplify git and github function

* chore: update deps

* refactor: update migrations and add badge to recognize compose type

* chore: update lock yaml

* refactor: use code editor

* feat: add monitoring for app types

* refactor: reset stats on change appName

* refactor: add option to clean monitoring folder

* feat: show current command that will run

* feat: add prefix

* fix: add missing types

* refactor: add docker provider and expose by default as false

* refactor: customize error page

* refactor: unified deployments to be a single one

* feat: add vitest to ci/cd

* revert: back to initial version

* refactor: add maxconcurrency vitest

* refactor: add pool forks to vitest

* feat: add pocketbase template

* fix: update path resolution compose

* removed

* feat: add template pocketbase

* feat: add pocketbase template

* feat: add support button

* feat: add plausible template

* feat: add calcom template

* feat: add version to each template

* feat: add code editor to enviroment variables and swarm settings json

* refactor: add loader when download the image

* fix: use base64 to generate keys plausible

* feat: add recognized domain names by enviroment compose

* refactor: show alert to redeploy in each card advanced tab

* refactor: add validation to prevent create compose if not have permissions

* chore: add templates section to contributing

* chore: add example contributing

* chore: add recomendation to show variables

* chore: add video to contributing templates

* chore: bump version

---------

Co-authored-by: hehehai <riverhohai@gmail.com>
Co-authored-by: Bayram Tagiev <bayram.tagiev.a@gmail.com>
Co-authored-by: Paulo Santana <30875229+hikinine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create application with docker-compose?
3 participants