How to set up remote staging environment with Traefik & Docker?

I have two working targets:
image
image

The remote docker target is run on Digital Ocean, using Traefik for SSL and connected to the domain succesfully.

I want to add a third environment to use as development, like a dev.website.com where I can push updates to and get test it remotely before deploying to production.

How do I do that?

I tried to create a new target in the Project Settings → Point to same docker machine → Set Web Server URL to dev.website.com.

But this broke the current production target, in Portainer I could see that things are trying to run on conflicting ports and I think that the root domain was getting routed to the staging docker container.

Bump. Any suggestions? Perhaps other ways of setting up a staging environment?

Each of your targets must point to a unique docker container/machine. There is no sharing of the machines.

Ah so there’s really no way to share a machine? I tried to set up 2 docker images on 1 digital ocean droplet

I’m assuming there is a way to do that, but I don’t believe Wappler natively supports. I’ve never tried though.

1 Like

@mebeingken
Hi Ken, I have been looking into this as well. The idea of having to spin up a separate droplet for each site seems to be a bit expensive. The use case I have in mind is when using subdomains on the same main domain and Traefik as the reverse proxy. Following @George steps for setting up Traefik, I set up separate targets letting Traefik create the subdomain for me by entering the full subdomain in the webserver URL portion of the targets settings (leave port empty)

The question as I took it was that @karh wanted to know how to stage each of these targets with wappler on the local target. I too have this question. Does anyone have a solution?

I’m not exactly sure what you are looking to achieve, but I’ll add some more thoughts in hopes of helping.

By way of example, I am building an app that supports a multi-tenant environment that can each have its own sub-domain (or external custom domain.) This is one Wappler project, deployed to one target (one each for Dev, Staging, and Production.) I setup apache to support a wild-card domain, and then alias all the custom domains in as well, and produce an ssl cert that supports it all. This single apache virtual host then proxies to the single node app.

For an example, let’s say we have a university program for client who wants separate structural areas for each focus area and separate subs. Two separate sub domain are created: https://area1.university.edu, https://area2.university.edu.

The issue, how to accomplish this in Wappler using a single droplet. Using Traefik you can indeed setup separate targets to create separate subs, but to make everything work I think you would need the following:

  1. create and map a directory for each of the subs on the remote machine
  2. create a separate folder on the local machine for each sub as well.

Hope that conveys the question better?

Doing that in Wappler is the issue. There are tutorials on DO and other sites that show you how to do this with Traefik or Apache virtual sites… I just cant figure out how to do it on Wappler. Was this @karh question as well?

1 Like

I guess my original answer stands then…I don’t think you can do this natively in Wappler, but I’ve never tried.

1 Like

After playing with the setup a bit more I was able to accomplish the task by creating a new project.
After creating a new project and selecting a new local folder I created a new remote target, choose the docker-machine created earlier, and in the WEB section entered the new subdomain as the url. This created the new sub and everything worked perfectly. Except for the database containers created an error. Not sure what to do here but making progress.

@dmbe11 Yes Daniel, I think we are trying to achieve the same here.

I don’t recall exactly but I think I’ve done the same as you wrote in your last comment. But I was hosting the database/webserver on the same ports which caused errors.

I could figure that out by using portainer and checking which containers are running.

I ended up corrupting most of it and created a whole new droplet by wappler :sweat_smile:
Still very keen to get it working but almost resorted to simply getting another droplet. I think we need to do this to get it working: https://www.digitalocean.com/community/questions/how-to-set-publish-2-containers-on-one-droplet

So first start the containers on different ports (hopefully through the target settings like you just tried).
Secondly, set up Traefik as a reverse proxy. (No idea how yet)

PS @mebeingken this project is also a multi-tenant environment. Can you share a few more details? Are you using Node and Docker? Apache is used instead of docker, no?

Actually you can already publish multiple Wappler projects on a single docker server.

You just use the same docker machine.

It is not recommended however to use different docker database servers for each project as it will result in creating multiple database servers in your single docker server and those are pretty memory intensive.

So in short - you can have as many Wappler web projects as you wish on a single server, but try letting them use a central database server or a separate managed database.

Any guidance on how to share the databases using wappler?

So:

  1. We have a docker running on a digital ocean droplet (production)
  2. I want a staging target that shares the same database of (1)

Yes, for this project I am using apache with node...no docker involved here. I did some testing to load it in a DO app container but I forgot about a custom server requirement which ruled that out (at least until I re-tool something.)

Currently the best option is to use central database like a managed database on digital ocean for multiple projects.

@George posted a topic on using the DO-managed MySQL database: https://community.wappler.io/t/creating-database-connections-with-the-database-manager/20664 which I am going to try. It makes sense that you don’t want multiple databases running for each project and DO manages it for you.

Thanks @dmbe11 I was planning to use a managed DO database in the future anyhow.

Might push this forward… please do keep me updated if you can! I will do the same :slight_smile:

I did notice something that might save you some time, when setting up the remote database connection your managed database on DO, if you select the “Digital Oceans RDS” setting in the SSL section of the dialog box, you will receive an error. To fix I choose the default setting and it worked fine.

1 Like

Do you mean that in two different projects I can put the same docker machine and it will work ?
Can i use also different subdomains for each project ?

Like sub1.domain.com and sub2.domain.com?

Using the same server for multiple projects is now possible with the new Resource Manager and cloud providers there.

2 Likes