• Stars
    star
    765
  • Rank 59,372 (Top 2 %)
  • Language
    PHP
  • License
    Other
  • Created almost 4 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An open source tool that lets you create a SaaS website from docker images in 10 minutes.

简体中文

Screenshots

for members ( who subscribe the plan )

index pricing subscription

for admin

settings members plans droplets

⚠️ This document was translated into English by deepl and can be improved by PR

An open source tool that lets you create SaaS websites from images in as little as 10 minutes.

Docker2SaaS is a tool that enables multi-tenancy through virtualization technology (calling cloud platform api ) with tenant management and subscription managment. It helps web application and service developers to quickly build websites for sale or subscription. All you need to do is make an image of your application and then set up and configure a Docker2SaaS site to start selling your application as a service.

When a user's subscription is successful, it automatically creates a VPS from the image as configured; when the user cancels the subscription and it expires, it automatically deletes the VPS. Users can login to the site and see their subscription, host IP information, and other details. Additional extensions can be added.

The diagram below shows how Docker2SaaS interacts between: End Users
Payment provider: Stripe Cloud service provider: DigitalOcean.

Target Users of Docker2SaaS

Docker2SaaS is aimed at developers of cloud applications, providing them with a solution to quickly monetize their applications.

Let's say you develop a nice little web app and open source it to Github. Developers easily build it and use it on their own, but as the app becomes more popular, so do non-technical users. But even if they have already made a docker file, it is still difficult for them.

At this point you may want to provide a cloud hosting version. On the one hand, you can solve the details of the build for non-technical users, and on the other hand, hosting can bring some profit, so you can get a financial return.

However, this can create an additional amount of development, and it doesn't seem wise to spend weeks on development before you know if cloud hosting will be popular.

Fortunately, the open source Docker2SaaS solves this problem, and it only takes ten minutes to configure and you can get a simple and usable cloud hosting sales site. It's immediately ready for early sales, and you can modify the source code to add more business-related features as user demand increases.

Of course, it can also be used to build a third-party sales site under the license of a cloud application developer. But overall, Docker2SaaS is designed for developers and does not take into account the experience of non-technical users, so if you don't have a technical background, it's better to use a Docker2SaaS site that someone else has built rather than building it yourself.

PS: Docker2SaaS is built on Laravel, and while no knowledge is required for a simple deployment, if you want to customize and add features, then you need to have a little Laravel development knowledge.

Docker2Saas is licensed under the GPLv2 with an additional non-compete clause.

Docker2SaaS Guide

Steps

Digital Ocean configuration

Create a Digital Ocean image

We assume that you have already made a docker image of your application and can start it with the docker-compose command. Let's use Ghost as an example to explain.

First we will create a droplet( Digital Ocean calls its VPS droplet ) on Digital Ocean and select docker on ubuntu under marketplace.

Then we log in to the newly created instance via SSH. Create our docker-compose.yaml file in the root directory (or somewhere else). Here we use the yaml provided by bitnami.

version: '2'
services:
  mariadb:
    restart: always
    image: 'docker.io/bitnami/mariadb:10.3-debian-10'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_ghost
      - MARIADB_DATABASE=bitnami_ghost
    volumes:
      - 'mariadb_data:/bitnami'
  ghost:
    restart: always
    image: 'docker.io/bitnami/ghost:3-debian-10'
    environment:
      - MARIADB_HOST=mariadb
      - MARIADB_PORT_NUMBER=3306
      - GHOST_DATABASE_USER=bn_ghost
      - GHOST_DATABASE_NAME=bitnami_ghost
      - ALLOW_EMPTY_PASSWORD=yes
      - GHOST_HOST=localhost
      - [email protected]
      - GHOST_PASSWORD=admin
    ports:
      - '80:2368'
    volumes:
      - 'ghost_data:/bitnami'
    depends_on:
      - mariadb
volumes:
  mariadb_data:
    driver: local
  ghost_data:
    driver: local

Note that we have added restart: always to ensure that docker is started automatically when the image is started.

Once the file is created, go to droplet management and create a snapshot.

When you are done creating the snapshot, you can delete the droplet instance.

Go to the images page and look up the data-id of the snapshot in the source code corresponding to the snapshot entry you just created, this value (78661121 in the image) is the id of the snapshot. Record it, and we'll use it later. (We'll call this A1)

Creating a Digital Ocean Token

Next we will create a token so that we can manage droplet through the API. At the bottom of the left menu, select API.

In the Tokens/Keys tab, generate a new token with the read && write permissions selected. Once generated, record it and you will need it later. (We'll call it A2)

Stripe Configuration

The following are all described in Test mode.

Create a subscription

Go to the Stripe dashboard and create a product.

Note that in the Pricing section, select Recurring so that it will automatically renew. Fill in the rest of the fields as you wish.

After creating the product, go to the product details page, and you can see the API ID in the Pricing section, and record it. (We'll write it down as B1)

You can create as many prices as you need, remember to record the price ids.

Get API key

In order to interact with the Stripe platform through the API, we also need the API key. click the Developer menu on the left, select API Keys, and record the publishable key and secret key on the right. (Note B2, B3)

Since then, the preparation is done.

Configuring Docker2SaaS

Site initialization

Download/clone the docker2saas source code to the environment where you want to run the sales site. This environment needs to be configured with PHP7.4+ and MySQL.

git clone https://gitlab.com/easychen/docker-2-saas.git --depth=1 docker2saas

Initialization of dependency packages:

cd docker2saas 
composer install

Rename .env.example to .env and run the command to generate APP_KEY

php artisan key:generate

Fill in other relevant information.

  1. APP_DEBUG : should be set to false after debugging is completed
  2. APP_URL : Website URL
  3. APP_LOGO_URL and APP_ICON_URL: Home page big picture and top menu icon
  4. DB_*: database related configuration
  5. STRIPE_KEY: the B2 in the previous article
  6. STRIPE_SECRET: B3 in the previous section

After creating the database docker2saas in MySQL, then run the command to initialize the database.

php artisan migrate

Start the development environment

php artisan serve --host=0.0.0.0 --port=8001

You can see the website by accessing port 8001 of the machine ip. Click register to register users and login automatically, the first registered user will become administrator automatically.

The administrator's logic can be modified in app/Providers/AuthServiceProvider.php.

Gate::define('saas-admin', function (User $user) {
            return $user->id == 1;         
});

Configure the site

Click on the settings tab to configure the basic information for the site, where DigitalOcean token is A2 from above.

The DigitalOcean sshkey is the public key you want to use to manage all droplets. if you don't have one ready, you can create one by running the following command.

ssh-keygen -t rsa  -f <name>

During the run, if you don't want to set the passphrase, you can just press enter twice to set it to empty.

ssh-keygen -t rsa  -f this
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 

When this is done, .pub will be generated in the command directory, and its contents will be the sshkey we want to fill in the form.

Create a subscription plan

Click Add a plan on the Plans page to add a subscription plan.

  1. Name: the name of the plan visible to the user, e.g. pro
  2. Stripe Price ID: B1 in the previous article
  3. DigitalOcean Droplet Region: the region where the created cloud host is located
  4. DigitalOcean Droplet Size: the model of the created cloud host

The region and size values can be obtained from the Digital Ocean official website on the Create Droplet page. After you have selected the desired region and model, the default name of the generated cloud host is the size in the selected section as shown below, followed by the sgp1 section which is the region.

  1. DigitalOcean Droplet Image: A1 in the previous section
  2. DigitalOcean Droplet User Data: Custom information that can be accessed in the cloud host, which can be used to pass information about the purchased user, such as email, etc. The details of what is used will be explained later. You can leave it blank for now.

After saving, you will get a Link in the list screen, which you can click to enter the subscription process of the plan. (This link is called C1)

Click on the Pricing page to see a preset plan display page.

This page can be customized by editing resources/views/pricing.blade.php. This page uses the blade syntax, but is composed almost entirely of HTML, so it is not too difficult to modify.

In addition to modifying the style and service offerings, you should pay special attention to the Subscribe button below, which should link to the corresponding plan, as in C1 above.

Similarly, edit resources/views/dashboard.blade.php to modify the dashboard page that users see after registering, where you can add instructions and help related to the cloud service.

Other configuration items

Timed tasks

Docker2Saas monitors expired users daily and removes their cloud hosts. To be able to execute it regularly, you need to add the commands for this item to the system crontab:. macos/deepLFree.translatedWithDeepL.text

* * * * * php </path/to/docker2saas>/artisan schedule:run

Webhook

Since users can modify their subscriptions on the Stripe website, subscription modifications and payment confirmations in Docker2Saas are done via webhook.

The webhook requires an externally accessible URL, which is recommended to be configured after going live. If you are debugging locally, you can use ngrok for intranet penetration.

Suppose the URL of Docker2Saas website is http://D.com, then the webhook endpoint URL is http://D.com/stripe/webhook.

Select the following events at events to send.

  1. invoice.created
  2. invoice.paid
  3. invoice.payment_action_required
  4. customer.subscription.created
  5. customer.subscription.updated
  6. customer.subscription.deleted
  7. customer.created
  8. customer.updated
  9. customer.deleted

Note that the customer.subscription.updated is a subscription change, which is not handled by default as it involves the specific hierarchy logic behind the cloud application. You can implement it yourself in app/Http/Controllers/WebhookController.php.

At this point, the site is ready for normal transactions. Note that here we are using develop server for debugging, and in order to support more users, you should switch to dedicated server software such as Nginx. For details, please refer here.

Initializing a mirror using user data

In a Ghost mirror, we need to know the IP address or domain name of the current droplet to configure the connection path; we also need to know the email address of the user to create a default account for them.

So we need a way to get user information in the mirror. When creating the plan above, we have a user data option (noted as F1) that is used to do just that.

This is a mechanism provided by Digital Ocean, in all droplets, just visit http:// 169.254.169.254/metadata/v1/user-data to get the information passed in during creation.

You can view it in droplet with the curl command.

curl http://169.254.169.254/metadata/v1/user-data

But there is a problem that each user has a different email address. So we need to have variables to support when we fill in the F1 place. Here Docker2Saas provides $user variables via the blade syntax, so you can insert the user id via {{$user->id}} and the email via {{$user->email}}.

uid={{$user->id}}

You can even put the docker-compose.yml template directly at F1.

Of course, in the droplet image, you also need to configure the appropriate startup script to get this data and configure it.

In addition, through curl http://169.254.169.254/metadata/v1 you can also get droplet related information, such as ip, domain name, etc. For the specific format, please refer to the related documentation.

License

This project uses the GPLv2 License with conditions.

Both individuals and commercial companies can use Docker2SaaS to build their own cloud application sales sites under the GPLv2 license.

However, selling Docker2SaaS itself as a Cloud Hosting service (e.g., making Docker2SaaS an image and selling it as a cloud service through Docker2SaaS or other platforms) is prohibited.

More Repositories

1

howto-make-more-money

程序员如何优雅的挣零花钱,2.0版,升级为小书了。Most of this not work outside China , so no English translate
PHP
16,190
star
2

lean-side-bussiness

精益副业:程序员如何优雅地做副业
8,305
star
3

pushdeer

开放源码的无App推送服务,iOS14+扫码即用。亦支持快应用/iOS和Mac客户端、Android客户端、自制设备
C
4,353
star
4

one-person-businesses-methodology

一人公司方法论
3,220
star
5

stack-roadmap

方糖全栈路线图2023,为「从螺丝钉到一人企业」补全技能栈
PHP
3,063
star
6

CookieCloud

CookieCloud是一个和自架服务器同步浏览器Cookie和LocalStorage的小工具,支持端对端加密,可设定同步时间间隔。本仓库包含了插件和服务器端源码。CookieCloud is a small tool for synchronizing browser cookies and LocalStorage with a self-hosted server. It supports end-to-end encryption and allows for setting the synchronization interval. This repository contains both the plugin and the server-side source code
JavaScript
1,581
star
7

checkchan-dist

Check酱:监测网页内容变化,并发送异动到微信。亦支持http status、json和rss监测。配合自架云端,关电脑后也能运行。
JavaScript
1,532
star
8

openai-api-proxy

一行Docker命令部署的 OpenAI/GPT API代理,支持SSE流式返回、腾讯云函数 。Simple proxy for OpenAi api via a one-line docker command
JavaScript
1,450
star
9

openai-gpt-dev-notes-for-cn-developer

如何快速开发一个OpenAI/GPT应用:国内开发者笔记
Shell
1,403
star
10

wecomchan

微信推送服务Server酱的开源替代。通过企业微信向微信推送消息的配置文档、直推函数和可自行搭建的在线服务代码。
Go
1,233
star
11

chatchan-dist

Chat酱独立部署版,docker方案自带代理
Dockerfile
729
star
12

catgate

CatGate is a small crawler framework based on Chrome extension . CatGate是一个基于浏览器插件的数据抓取工具。做成浏览器插件无需模拟登入,能最真实的模仿用户行为和特征。
Vue
673
star
13

TeamToy

企业协同办公工具TeamToy2(多人TODO版)官方Git源
PHP
662
star
14

LazyPHP

轻框架。包含一个前端控制器,20个常用函数和用于页面布局的Layout系统,10分钟即可学会。LP采用BSD开源协议,在代码内保留框架名即可随意商用。
PHP
573
star
15

rsspush

监测RSS变动,并发送最新内容到微信、Webhook 和 Telegram, Discord, Slack, Amazon SNS, Gotify 等数十个消息通道。
499
star
16

telechan

message api for telegram bot 可供多人发送消息的 telegram 机器人 api , 类似server酱的开源实现
TypeScript
414
star
17

not-only-fans

an open source, self-hosted digital content subscription platform like `onlyfans.com` with cryptocurrency payment
HTML
356
star
18

career-guide-for-cs-graduate

计算机系应届生求职指北
316
star
19

LazyPHP4

LazyPHP4 , an API first framework for php developer
PHP
313
star
20

MemberPrism2

open source alternative to memberstack / memberspace , but with both front and backend member-only content protection
PHP
273
star
21

http-t-shirts

Open source http status code T shirt · http状态码系列T恤设计稿
266
star
22

tumblr-like-exporter

Download tumblr photos you liked , or others liked . Or even images in your blog . It supports videos now , see README to enable it
PHP
262
star
23

LazyRest4

基于Web界面的Rest风格API生成器For LazyPHP4
PHP
244
star
24

botchan

基于微信测试号的ChatBot,对接OpenAI API
JavaScript
242
star
25

lianmilite

莲米粒是一个基于PHP+MySQL+微信小程序技术栈的、拥有用户登入、发布、修改、删除和转发信息、以及私信聊天模块的信息流应用。
PHP
233
star
26

deepgpt-dist

DeepGPT,类agentGPT/AutoGPT 工具,支持 api2d / 和自定义 openai key。此为静态网页独立部署版,部署方便
JavaScript
227
star
27

book-by-ai

Generate high-quality books with AI
JavaScript
216
star
28

TeamToy-Pocket

TeamToy是跨平台的团队TODO应用,官网 TeamToy.net。 TeamToyPocket是其移动客户端。本项目采用GPLV2协议,本分支代码用于在新浪移动云上直接打包。如果自行用PhoneGap打包,请将代码中<phonegap></phonegap>换成phonegap.js的路径。
JavaScript
203
star
29

LazyREST

可通过Web配置的REST Server,采用GPLV2授权
PHP
193
star
30

gpt-bat

GPT长文本批处理工具,Batch Processing tools for GPT
JavaScript
184
star
31

LazyAudioBook

将 txt 文件生成语音书。
PHP
167
star
32

flowdeer-dist

可用于深度思考和复杂流程的AI工具
163
star
33

LeanBase

143
star
34

aiapi

A Claude-driven, OpenAI specification-compliant API, free
135
star
35

onlytech-javascript-info

纯粹技术免费课计划·现代JavaScript 教程
112
star
36

timetodo-server

remote server for timetodo
PHP
108
star
37

windrecorder

JavaScript
103
star
38

rumenqi

从入门到放弃系列周边补全计划
98
star
39

api2d-js

OpenAI/Api2d pure js sdk 无需node后端直接在浏览器中运行,支持SSE流式输出
JavaScript
90
star
40

fangPHP

fangPHP is a docker based development env with php7 mysql redis and livereload
PHP
84
star
41

any2api

A framework( or a tool? ) that turns any website into an API
JavaScript
81
star
42

h2webreader

h2book web reader
JavaScript
78
star
43

awesome-checkchan

Check酱任务分享清单
76
star
44

windmark-practice

采用 windmark 编写的视频的源文件
74
star
45

h2reader-host

方糖小剧场Web阅读器和上传网站
JavaScript
72
star
46

Simple-Weibo

PS: 这个方案有些过时了,建议用新方案 https://github.com/qhm123/tinybo open source phonegap weibo client demo 。想要更多功能的同学自己写嘛,别偷懒哈。
JavaScript
70
star
47

url2pdf

url2pdf docker image based on wkhtmltopdf with Chinese support.
PHP
68
star
48

code-tattoo

语言纹身贴纸图案库
60
star
49

GPT4Company

Gpt4Company is a request forwarder used to prevent Samsung-style leaks. Gpt4Company 是一个用来避免三星式泄密的请求转发器
JavaScript
57
star
50

ffonline

video creating in browser
JavaScript
57
star
51

LazyBoardExt

定时采集数据并发送到指定接口的Chrome扩展机器人🤖
JavaScript
54
star
52

nCoV-push

nCoV疫情实时播报推送脚本。数据基于丁香园。
PHP
53
star
53

Wechat-Wordpress-Search

a wordpress plugin allowed user search blogs in wechat app
PHP
52
star
54

MoDocker

modo动漫私有云(modo.moe)的Docker构建用文件。
PHP
40
star
55

ask-gpt-download

通过GPT向微博账号提问
39
star
56

WindChat

A React Chatbot starter with highly customizable styles can be achieved through TailwindCSS. 可以通过 TailwindCSS 高度定制样式的 React Chatbot starter。
JavaScript
36
star
57

fo-pay

基于加密稳定币 FOUSDT 的 WordPress 付费阅读插件。
PHP
33
star
58

Fangtang-Chrome-Starter-Kit

Starter Kit for chrome extension based on Vue2 and ElementUI
JavaScript
33
star
59

serverchan-demo

Server酱多语言调用实例
Java
31
star
60

vue-starter

JavaScript
27
star
61

fangtangtree

方糖知识树
26
star
62

nowboard

基于SAE Channel服务的实时信息流展板。通过微博帐号登入、可聊天;支持API发布信息,可用于服务器调试信息、错误信息展示。
PHP
26
star
63

TeamToy-Plugins

TeamToy插件目录
PHP
24
star
64

LazyExtKit

a simple chrome extension startkit
JavaScript
24
star
65

github-action-server-chan

TypeScript
23
star
66

MetaToy2

通用命令行和可视化代码生成工具
EJS
19
star
67

WeiboList

微博上活跃的技术帐号整理
19
star
68

easy-starter2

react + mobx + react-router v4 + react-next-i18n starter for create-react-app 2.x
JavaScript
17
star
69

fangtangCV-react-native

react native demo
JavaScript
16
star
70

serverchan-wordpress-comments-notice

Server酱WordPress博客评论微信通知插件
PHP
16
star
71

easy-starter

一个整合了 react 、 react-router v4 和 mobx 的简单起始项目脚手架
JavaScript
15
star
72

LazyBot

一些基于 robo.li 的日常自动化/半自动化脚本
PHP
15
star
73

one-person-businesses-methodology-v2

用AI撰写的一本小书
Shell
14
star
74

teamtoy-mina-demo

一个调用TeamToy API 的微信小程序 Demo
JavaScript
14
star
75

CubismWebSamples-with-lip-sync

TypeScript
14
star
76

fullstack-learnning-map

全栈创业者(fullstack-creator)的知识地图
13
star
77

fangtangCV

PHP
12
star
78

2dstudio-dist

使用 API2D Key 的 Stable Studio,独立部署版
HTML
12
star
79

Aoi

LazyPHP3的看板娘,能帮你自动创建模板,Action和测试。
PHP
12
star
80

xf-tts-sdk

php & node sdk for xunfei tts websocket api
JavaScript
10
star
81

easychen.github.com

8
star
82

tcp

tcp包介绍网站
CSS
8
star
83

autoplay-web-specification

自播放网页规范 specification of autoplay web
7
star
84

imgShare

为文章中的图片添加鼠标浮动时分享到微博的链接。封装自 国内首家互联网人才拍卖网站 JobDeer.com
JavaScript
6
star
85

fangtangGif

方糖动图生成器
6
star
86

telegram-bot-api-proxy

express app for forwarding request to api.telegram.org
JavaScript
4
star
87

GameDemo

DemoGame for FE courses , Just a hosting , not open source project
4
star
88

easychen.github.io

HTML
4
star
89

book-by-ai-demo-book

3
star
90

wordpress-local-dev-env

3
star
91

LitePHP

Simple version of LazyPHP in one file
PHP
3
star
92

serverchan-e2e-demo

Server酱端对端加密函数和DEMO
2
star
93

fangCV

PHP
2
star
94

easychen

2
star
95

cubeslam

Automatically exported from code.google.com/p/cubeslam
JavaScript
2
star
96

TeamToy-Language-Files

translate teamtoy to other languages
PHP
2
star
97

fxd

Flow eXtension Define,它是一个被设计用于工作流(尤其是AI和自动化工作流)扩展的规范。"Flow eXtension Define" is a specification designed for extending workflows, especially AI and automation workflows.
JavaScript
2
star
98

bluesky-wave

Bluesky bulk follow tool
JavaScript
2
star
99

serverchan3-doc

Server酱³文档网站
MDX
1
star
100

2d-ai-chatbot

TypeScript
1
star