Merge branch 'master' into budi-7105-builder-option-for-read-only-form-fields
This commit is contained in:
commit
8475df9352
|
@ -66,14 +66,21 @@ jobs:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
|
build-args: BUDIBASE_VERSION=$BUDIBASE_VERSION
|
||||||
tags: budibase/budibase,budibase/budibase:${{ env.RELEASE_VERSION }}
|
tags: budibase/budibase,budibase/budibase:${{ env.RELEASE_VERSION }}
|
||||||
file: ./hosting/single/Dockerfile.v2
|
file: ./hosting/single/Dockerfile.v2
|
||||||
|
env:
|
||||||
|
BUDIBASE_VERSION: ${{ env.RELEASE_VERSION }}
|
||||||
- name: Tag and release Budibase Azure App Service docker image
|
- name: Tag and release Budibase Azure App Service docker image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
build-args: TARGETBUILD=aas
|
build-args: |
|
||||||
|
TARGETBUILD=aas
|
||||||
|
BUDIBASE_VERSION=$BUDIBASE_VERSION
|
||||||
tags: budibase/budibase-aas,budibase/budibase-aas:${{ env.RELEASE_VERSION }}
|
tags: budibase/budibase-aas,budibase/budibase-aas:${{ env.RELEASE_VERSION }}
|
||||||
file: ./hosting/single/Dockerfile.v2
|
file: ./hosting/single/Dockerfile.v2
|
||||||
|
env:
|
||||||
|
BUDIBASE_VERSION: ${{ env.RELEASE_VERSION }}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
if [[ $TARGETARCH == arm* ]] ;
|
|
||||||
then
|
|
||||||
echo "INSTALLING ARM64 MINIO"
|
|
||||||
wget https://dl.min.io/server/minio/release/linux-arm64/minio
|
|
||||||
else
|
|
||||||
echo "INSTALLING AMD64 MINIO"
|
|
||||||
wget https://dl.min.io/server/minio/release/linux-amd64/minio
|
|
||||||
fi
|
|
||||||
chmod +x minio
|
|
|
@ -42,6 +42,7 @@ COPY packages/string-templates packages/string-templates
|
||||||
FROM budibase/couchdb as runner
|
FROM budibase/couchdb as runner
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ENV TARGETARCH $TARGETARCH
|
ENV TARGETARCH $TARGETARCH
|
||||||
|
ENV NODE_MAJOR 18
|
||||||
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
|
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
|
||||||
# e.g. docker build --build-arg TARGETBUILD=aas ....
|
# e.g. docker build --build-arg TARGETBUILD=aas ....
|
||||||
ARG TARGETBUILD=single
|
ARG TARGETBUILD=single
|
||||||
|
@ -49,10 +50,10 @@ ENV TARGETBUILD $TARGETBUILD
|
||||||
|
|
||||||
# install base dependencies
|
# install base dependencies
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server
|
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server libaio1
|
||||||
|
|
||||||
# Install postgres client for pg_dump utils
|
# Install postgres client for pg_dump utils
|
||||||
RUN apt install software-properties-common apt-transport-https gpg -y \
|
RUN apt install -y software-properties-common apt-transport-https ca-certificates gnupg \
|
||||||
&& curl -fsSl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null \
|
&& curl -fsSl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null \
|
||||||
&& echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main | tee /etc/apt/sources.list.d/postgresql.list \
|
&& echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main | tee /etc/apt/sources.list.d/postgresql.list \
|
||||||
&& apt update -y \
|
&& apt update -y \
|
||||||
|
@ -61,10 +62,8 @@ RUN apt install software-properties-common apt-transport-https gpg -y \
|
||||||
|
|
||||||
# install other dependencies, nodejs, oracle requirements, jdk8, redis, nginx
|
# install other dependencies, nodejs, oracle requirements, jdk8, redis, nginx
|
||||||
WORKDIR /nodejs
|
WORKDIR /nodejs
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh && \
|
COPY scripts/install-node.sh ./install.sh
|
||||||
bash /tmp/nodesource_setup.sh && \
|
RUN chmod +x install.sh && ./install.sh
|
||||||
apt-get install -y --no-install-recommends libaio1 nodejs && \
|
|
||||||
npm install --global yarn pm2
|
|
||||||
|
|
||||||
# setup nginx
|
# setup nginx
|
||||||
COPY hosting/single/nginx/nginx.conf /etc/nginx
|
COPY hosting/single/nginx/nginx.conf /etc/nginx
|
||||||
|
|
|
@ -77,7 +77,7 @@ mkdir -p ${DATA_DIR}/minio
|
||||||
chown -R couchdb:couchdb ${DATA_DIR}/couch
|
chown -R couchdb:couchdb ${DATA_DIR}/couch
|
||||||
redis-server --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 &
|
redis-server --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 &
|
||||||
/bbcouch-runner.sh &
|
/bbcouch-runner.sh &
|
||||||
/minio/minio server --console-address ":9001" ${DATA_DIR}/minio > /dev/stdout 2>&1 &
|
minio server --console-address ":9001" ${DATA_DIR}/minio > /dev/stdout 2>&1 &
|
||||||
/etc/init.d/nginx restart
|
/etc/init.d/nginx restart
|
||||||
if [[ ! -z "${CUSTOM_DOMAIN}" ]]; then
|
if [[ ! -z "${CUSTOM_DOMAIN}" ]]; then
|
||||||
# Add monthly cron job to renew certbot certificate
|
# Add monthly cron job to renew certbot certificate
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.12.2",
|
"version": "2.12.4",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"test:notify": "node scripts/testResultsWebhook",
|
"test:notify": "node scripts/testResultsWebhook",
|
||||||
"test:cloud:prod": "yarn run test --testPathIgnorePatterns=\\.integration\\.",
|
"test:cloud:prod": "yarn run test --testPathIgnorePatterns=\\.integration\\.",
|
||||||
"test:cloud:qa": "yarn run test",
|
"test:cloud:qa": "yarn run test",
|
||||||
"test:self:ci": "yarn run test --testPathIgnorePatterns=\\.integration\\. \\.cloud\\. \\.license\\.",
|
"test:self:ci": "yarn run test --testPathIgnorePatterns=\\.integration\\. \\.cloud\\. \\.licensing\\.",
|
||||||
"serve:test:self:ci": "start-server-and-test dev:built http://localhost:4001/health test:self:ci",
|
"serve:test:self:ci": "start-server-and-test dev:built http://localhost:4001/health test:self:ci",
|
||||||
"serve": "start-server-and-test dev:built http://localhost:4001/health",
|
"serve": "start-server-and-test dev:built http://localhost:4001/health",
|
||||||
"dev:built": "cd ../ && yarn dev:built"
|
"dev:built": "cd ../ && yarn dev:built"
|
||||||
|
|
|
@ -99,9 +99,11 @@ export default class LicenseAPI extends BaseAPI {
|
||||||
}, opts)
|
}, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
async updatePlan(opts: APIRequestOpts = { status: 200 }) {
|
async updatePlan(priceId: string, opts: APIRequestOpts = { status: 200 }) {
|
||||||
return this.doRequest(() => {
|
return this.doRequest(() => {
|
||||||
return this.client.put(`/api/license/plan`)
|
return this.client.put(`/api/license/plan`, {
|
||||||
|
body: { priceId },
|
||||||
|
})
|
||||||
}, opts)
|
}, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,19 @@ export default class StripeAPI extends BaseAPI {
|
||||||
}, opts)
|
}, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
async linkStripeCustomer(opts: APIRequestOpts = { status: 200 }) {
|
async linkStripeCustomer(
|
||||||
|
accountId: string,
|
||||||
|
stripeCustomerId: string,
|
||||||
|
opts: APIRequestOpts = { status: 200 }
|
||||||
|
) {
|
||||||
return this.doRequest(() => {
|
return this.doRequest(() => {
|
||||||
return this.client.post(`/api/stripe/link`)
|
return this.client.post(`/api/stripe/link`, {
|
||||||
|
body: {
|
||||||
|
accountId,
|
||||||
|
stripeCustomerId,
|
||||||
|
},
|
||||||
|
internal: true,
|
||||||
|
})
|
||||||
}, opts)
|
}, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
import TestConfiguration from "../../config/TestConfiguration"
|
||||||
|
import * as fixtures from "../../fixtures"
|
||||||
|
import { Hosting, PlanType } from "@budibase/types"
|
||||||
|
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY)
|
||||||
|
|
||||||
|
describe("license management", () => {
|
||||||
|
const config = new TestConfiguration()
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await config.beforeAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await config.afterAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("retrieves plans, creates checkout session, and updates license", async () => {
|
||||||
|
// Create cloud account
|
||||||
|
const createAccountRequest = fixtures.accounts.generateAccount({
|
||||||
|
hosting: Hosting.CLOUD,
|
||||||
|
})
|
||||||
|
const [createAccountRes, account] =
|
||||||
|
await config.accountsApi.accounts.create(createAccountRequest, {
|
||||||
|
autoVerify: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Self response has free license
|
||||||
|
await config.doInNewState(async () => {
|
||||||
|
await config.loginAsAccount(createAccountRequest)
|
||||||
|
const [selfRes, selfBody] = await config.api.accounts.self()
|
||||||
|
expect(selfBody.license.plan.type).toBe(PlanType.FREE)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Retrieve plans
|
||||||
|
const [plansRes, planBody] = await config.api.licenses.getPlans()
|
||||||
|
|
||||||
|
// Select priceId from premium plan
|
||||||
|
let premiumPriceId = null
|
||||||
|
let businessPriceId = ""
|
||||||
|
for (const plan of planBody) {
|
||||||
|
if (plan.type === PlanType.PREMIUM) {
|
||||||
|
premiumPriceId = plan.prices[0].priceId
|
||||||
|
}
|
||||||
|
if (plan.type === PlanType.BUSINESS) {
|
||||||
|
businessPriceId = plan.prices[0].priceId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create checkout session for price
|
||||||
|
const checkoutSessionRes = await config.api.stripe.createCheckoutSession(
|
||||||
|
premiumPriceId
|
||||||
|
)
|
||||||
|
const checkoutSessionUrl = checkoutSessionRes[1].url
|
||||||
|
expect(checkoutSessionUrl).toContain("checkout.stripe.com")
|
||||||
|
|
||||||
|
// Create stripe customer
|
||||||
|
const customer = await stripe.customers.create({
|
||||||
|
email: createAccountRequest.email,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Create payment method
|
||||||
|
const paymentMethod = await stripe.paymentMethods.create({
|
||||||
|
type: "card",
|
||||||
|
card: {
|
||||||
|
token: "tok_visa", // Test Visa Card
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Attach payment method to customer
|
||||||
|
await stripe.paymentMethods.attach(paymentMethod.id, {
|
||||||
|
customer: customer.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Update customer
|
||||||
|
await stripe.customers.update(customer.id, {
|
||||||
|
invoice_settings: {
|
||||||
|
default_payment_method: paymentMethod.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Create subscription for premium plan
|
||||||
|
const subscription = await stripe.subscriptions.create({
|
||||||
|
customer: customer.id,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
price: premiumPriceId,
|
||||||
|
quantity: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default_payment_method: paymentMethod.id,
|
||||||
|
collection_method: "charge_automatically",
|
||||||
|
})
|
||||||
|
|
||||||
|
await config.doInNewState(async () => {
|
||||||
|
// License updated from Free to Premium
|
||||||
|
await config.loginAsAccount(createAccountRequest)
|
||||||
|
await config.api.stripe.linkStripeCustomer(account.accountId, customer.id)
|
||||||
|
const [_, selfBodyPremium] = await config.api.accounts.self()
|
||||||
|
expect(selfBodyPremium.license.plan.type).toBe(PlanType.PREMIUM)
|
||||||
|
|
||||||
|
// Create portal session - Check URL
|
||||||
|
const [portalRes, portalSessionBody] =
|
||||||
|
await config.api.stripe.createPortalSession(customer.id)
|
||||||
|
expect(portalSessionBody.url).toContain("billing.stripe.com")
|
||||||
|
|
||||||
|
// Update subscription from premium to business license
|
||||||
|
await config.api.licenses.updatePlan(businessPriceId)
|
||||||
|
|
||||||
|
// License updated to Business
|
||||||
|
const [selfRes, selfBodyBusiness] = await config.api.accounts.self()
|
||||||
|
expect(selfBodyBusiness.license.plan.type).toBe(PlanType.BUSINESS)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
|
@ -28,6 +28,7 @@ const env = {
|
||||||
MARIADB_DB: process.env.MARIADB_DB,
|
MARIADB_DB: process.env.MARIADB_DB,
|
||||||
MARIADB_USER: process.env.MARIADB_USER,
|
MARIADB_USER: process.env.MARIADB_USER,
|
||||||
MARIADB_PASSWORD: process.env.MARIADB_PASSWORD,
|
MARIADB_PASSWORD: process.env.MARIADB_PASSWORD,
|
||||||
|
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
|
||||||
}
|
}
|
||||||
|
|
||||||
export = env
|
export = env
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
if [[ $TARGETARCH == arm* ]] ;
|
if [[ $TARGETARCH == arm* ]] ;
|
||||||
then
|
then
|
||||||
echo "INSTALLING ARM64 MINIO"
|
echo "INSTALLING ARM64 MINIO"
|
||||||
wget https://dl.min.io/server/minio/release/linux-arm64/minio
|
wget wget https://dl.min.io/server/minio/release/linux-arm64/archive/minio.deb -O minio.deb
|
||||||
else
|
else
|
||||||
echo "INSTALLING AMD64 MINIO"
|
echo "INSTALLING AMD64 MINIO"
|
||||||
wget https://dl.min.io/server/minio/release/linux-amd64/minio
|
wget wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio.deb -O minio.deb
|
||||||
fi
|
fi
|
||||||
chmod +x minio
|
dpkg -i minio.deb
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
apt-get install -y gnupg
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg > /dev/null
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
||||||
|
apt-get update
|
||||||
|
echo "INSTALLING NODE $NODE_MAJOR"
|
||||||
|
apt-get install -y --no-install-recommends nodejs
|
||||||
|
npm install --global yarn pm2
|
Loading…
Reference in New Issue