Skip to content

Commit

Permalink
fix(docker): 🐛 Runtime public environment
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jun 22, 2022
1 parent ea76564 commit e03fe9f
Show file tree
Hide file tree
Showing 54 changed files with 349 additions and 164 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ firebaseServiceAccount.json
tags

dump.sql

__env.js
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ COPY --from=builder /app/apps/${SCOPE}/.next/static ./.next/static
COPY --from=builder /app/apps/${SCOPE}/.env.docker ./.env.production
RUN apt-get -qy update && apt-get -qy install openssl

COPY entrypoint.sh ./
COPY env.sh ./
COPY ${SCOPE}-entrypoint.sh ./
RUN chmod +x ./${SCOPE}-entrypoint.sh
RUN chmod +x ./entrypoint.sh
RUN chmod +x ./env.sh
ENTRYPOINT ./${SCOPE}-entrypoint.sh

EXPOSE 3000
Expand Down
12 changes: 6 additions & 6 deletions apps/builder/.env.docker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Don't edit this file
NEXT_PUBLIC_VIEWER_URL=DOCKER_NEXT_PUBLIC_VIEWER_URL
NEXT_PUBLIC_SMTP_FROM=DOCKER_NEXT_PUBLIC_SMTP_FROM
NEXT_PUBLIC_GOOGLE_API_KEY=DOCKER_NEXT_PUBLIC_GOOGLE_API_KEY
NEXT_PUBLIC_GIPHY_API_KEY=DOCKER_NEXT_PUBLIC_GIPHY_API_KEY
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=DOCKER_NEXT_PUBLIC_STRIPE_PUBLIC_KEY
NEXT_PUBLIC_SENTRY_DSN=DOCKER_NEXT_PUBLIC_SENTRY_DSN
NEXT_PUBLIC_VIEWER_URL=
NEXT_PUBLIC_SMTP_FROM=
NEXT_PUBLIC_GOOGLE_API_KEY=
NEXT_PUBLIC_GIPHY_API_KEY=
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=
NEXT_PUBLIC_SENTRY_DSN=
5 changes: 2 additions & 3 deletions apps/builder/components/share/ShareContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { isDefined, isNotDefined } from 'utils'
import { CustomDomainsDropdown } from './customDomain/CustomDomainsDropdown'
import { EditableUrl } from './EditableUrl'
import { integrationsList } from './integrations/EmbedButton'
import { env } from 'utils'

export const ShareContent = () => {
const { workspace } = useWorkspace()
Expand Down Expand Up @@ -58,9 +59,7 @@ export const ShareContent = () => {
</Heading>
{typebot && (
<EditableUrl
hostname={
process.env.NEXT_PUBLIC_VIEWER_URL ?? 'https://typebot.io'
}
hostname={env('VIEWER_URL') ?? 'https://typebot.io'}
pathname={publicId}
onPathnameChange={handlePublicIdChange}
/>
Expand Down
8 changes: 4 additions & 4 deletions apps/builder/components/share/codeSnippets/Chat/EmbedCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BubbleParams } from 'typebot-js'
import { parseInitBubbleCode, typebotJsHtml } from '../params'
import { useTypebot } from 'contexts/TypebotContext'
import { CodeEditor } from 'components/shared/CodeEditor'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'

type ChatEmbedCodeProps = {
withStarterVariables?: boolean
Expand All @@ -21,9 +21,9 @@ export const ChatEmbedCode = ({
const snippet = prettier.format(
createSnippet({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`,
button,
proactiveMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parseInitContainerCode, typebotJsHtml } from '../params'
import { IframeParams } from 'typebot-js'
import { useTypebot } from 'contexts/TypebotContext'
import { CodeEditor } from 'components/shared/CodeEditor'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'

type ContainerEmbedCodeProps = {
widthLabel: string
Expand All @@ -23,9 +23,9 @@ export const ContainerEmbedCode = ({
const snippet = prettier.format(
parseSnippet({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`,
heightLabel,
widthLabel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FlexProps } from '@chakra-ui/react'
import { CodeEditor } from 'components/shared/CodeEditor'
import { useTypebot } from 'contexts/TypebotContext'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'

type Props = {
widthLabel: string
Expand All @@ -14,9 +14,9 @@ export const IframeEmbedCode = ({
}: Props & FlexProps) => {
const { typebot } = useTypebot()
const src = `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`
const code = `<iframe src="${src}" width="${widthLabel}" height="${heightLabel}" />`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTypebot } from 'contexts/TypebotContext'
import parserHtml from 'prettier/parser-html'
import prettier from 'prettier/standalone'
import { PopupParams } from 'typebot-js'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'
import { parseInitPopupCode, typebotJsHtml } from '../params'

type PopupEmbedCodeProps = {
Expand All @@ -18,9 +18,9 @@ export const PopupEmbedCode = ({ delay }: PopupEmbedCodeProps & FlexProps) => {
const snippet = prettier.format(
createSnippet({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`,
delay,
}),
Expand Down
20 changes: 10 additions & 10 deletions apps/builder/components/share/codeSnippets/ReactCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import parserBabel from 'prettier/parser-babel'
import prettier from 'prettier/standalone'
import { CodeEditor } from 'components/shared/CodeEditor'
import { useTypebot } from 'contexts/TypebotContext'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'

type StandardReactDivProps = { widthLabel: string; heightLabel: string }
export const StandardReactDiv = ({
Expand All @@ -21,9 +21,9 @@ export const StandardReactDiv = ({
const snippet = prettier.format(
parseContainerSnippet({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`,
heightLabel,
widthLabel,
Expand Down Expand Up @@ -73,9 +73,9 @@ export const PopupReactCode = ({ delay }: PopupEmbedCodeProps & FlexProps) => {
const snippet = prettier.format(
parsePopupSnippet({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`,
delay,
}),
Expand Down Expand Up @@ -124,9 +124,9 @@ export const ChatReactCode = ({
const snippet = prettier.format(
parseBubbleSnippet({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${typebot?.publicId}`,
button,
proactiveMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { useToast } from 'components/shared/hooks/useToast'
import { useEffect, useRef, useState } from 'react'
import { createCustomDomain } from 'services/user'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'

const hostnameRegex =
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/
Expand Down Expand Up @@ -118,9 +118,9 @@ export const CustomDomainModal = ({
<Stack>
<Text fontWeight="bold">Value</Text>
<Text>
{isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL}
{isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')}
</Text>
</Stack>
</HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PopupEmbedSettings } from 'components/share/codeSnippets/Popup/EmbedSet
import { CodeEditor } from 'components/shared/CodeEditor'
import { useState } from 'react'
import { BubbleParams } from 'typebot-js'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'
import { ModalProps } from '../../EmbedButton'

type GtmInstructionsProps = {
Expand Down Expand Up @@ -41,9 +41,9 @@ const StandardInstructions = ({ publicId }: Pick<ModalProps, 'publicId'>) => {

const jsCode = parseInitContainerCode({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${publicId}`,
})
const headCode = `${typebotJsHtml}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@chakra-ui/react'
import { CopyButton } from 'components/shared/buttons/CopyButton'
import { PublishFirstInfo } from 'components/shared/Info'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'
import { ModalProps } from '../EmbedButton'

export const NotionModal = ({
Expand Down Expand Up @@ -46,17 +46,17 @@ export const NotionModal = ({
pr="4.5rem"
type={'text'}
defaultValue={`${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${publicId}`}
/>
<InputRightElement width="4.5rem">
<CopyButton
textToCopy={`${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${publicId}`}
/>
</InputRightElement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { BubbleParams } from 'typebot-js'
import { ModalProps } from '../../EmbedButton'
import parserHtml from 'prettier/parser-html'
import prettier from 'prettier/standalone'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'

type ShopifyInstructionsProps = {
type: 'standard' | 'popup' | 'bubble'
Expand Down Expand Up @@ -46,9 +46,9 @@ const StandardInstructions = ({ publicId }: Pick<ModalProps, 'publicId'>) => {

const jsCode = parseInitContainerCode({
url: `${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${publicId}`,
})
const headCode = prettier.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { ExternalLinkIcon } from 'assets/icons'
import { CopyButton } from 'components/shared/buttons/CopyButton'
import { PublishFirstInfo } from 'components/shared/Info'
import { isEmpty } from 'utils'
import { env, isEmpty } from 'utils'
import { ModalProps } from '../EmbedButton'

export const WordpressModal = ({
Expand Down Expand Up @@ -55,17 +55,17 @@ export const WordpressModal = ({
pr="4.5rem"
type={'text'}
defaultValue={`${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${publicId}`}
/>
<InputRightElement width="4.5rem">
<CopyButton
textToCopy={`${
isEmpty(process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL)
? process.env.NEXT_PUBLIC_VIEWER_URL
: process.env.NEXT_PUBLIC_VIEWER_INTERNAL_URL
isEmpty(env('VIEWER_INTERNAL_URL'))
? env('VIEWER_URL')
: env('VIEWER_INTERNAL_URL')
}/${publicId}`}
/>
</InputRightElement>
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/components/shared/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useDebouncedCallback } from 'use-debounce'
import { linter } from '@codemirror/lint'
import { VariablesButton } from './buttons/VariablesButton'
import { Variable } from 'models'
import { isEmpty } from 'utils'
import { env } from 'utils'

const linterExtension = linter(jsonParseLinter())

Expand Down Expand Up @@ -43,7 +43,7 @@ export const CodeEditor = ({
setPlainTextValue(value)
onChange && onChange(value)
},
isEmpty(process.env.NEXT_PUBLIC_E2E_TEST) ? debounceTimeout : 0
env('E2E_TEST') === 'enabled' ? 0 : debounceTimeout
)

useEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SwitchWithLabel } from 'components/shared/SwitchWithLabel'
import { Input, Textarea } from 'components/shared/Textbox'
import { CredentialsType, SendEmailOptions } from 'models'
import React, { useState } from 'react'
import { env } from 'utils'
import { SmtpConfigModal } from './SmtpConfigModal'

type Props = {
Expand Down Expand Up @@ -96,9 +97,9 @@ export const SendEmailSettings = ({ options, onOptionsChange }: Props) => {
currentCredentialsId={options.credentialsId}
onCredentialsSelect={handleCredentialsSelect}
onCreateNewClick={onOpen}
defaultCredentialLabel={process.env.NEXT_PUBLIC_SMTP_FROM?.match(
/\<(.*)\>/
)?.pop()}
defaultCredentialLabel={env('SMTP_FROM')
?.match(/\<(.*)\>/)
?.pop()}
refreshDropdownKey={refreshCredentialsKey}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { Grid, SearchContext } from '@giphy/react-components'
import { GiphyLogo } from 'assets/logos'
import React, { useContext, useState, useEffect } from 'react'
import { useDebounce } from 'use-debounce'
import { env } from 'utils'

type GiphySearchProps = {
onSubmit: (url: string) => void
}

const giphyFetch = new GiphyFetch(
process.env.NEXT_PUBLIC_GIPHY_API_KEY as string
)
const giphyFetch = new GiphyFetch(env('GIPHY_API_KEY') as string)

export const GiphySearch = ({ onSubmit }: GiphySearchProps) => {
const { fetchGifs, searchKey, setSearch } = useContext(SearchContext)
Expand Down
Loading

5 comments on commit e03fe9f

@vercel
Copy link

@vercel vercel bot commented on e03fe9f Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

am.nigerias.io
vhpage.cr8.ai
bot.aws.bj
an.nigerias.io
ar.nigerias.io
sat.cr8.ai
aso.nigerias.io
apr.nigerias.io
bt.id8rs.com
apo.nigerias.io
chat.sureb4.com
eventhub.com.au
sakuranembro.it
bot.upfunnel.art
games.klujo.com
bot.piccinato.co
faqs.nigerias.io
clo.closeer.work
stan.vselise.com
feedback.ofx.one
voicehelp.cr8.ai
goalsettingbot.com
bot.eventhub.com.au
this-is-a-test.com
zap.techadviser.in
app.chatforms.net
bot.ansuraniphone.my
typebot.stillio.com
bot.cotemeuplano.com
forms.webisharp.com
chat.hayurihijab.com
get.freebotoffer.xyz
bot.incusservices.com
bot.meuesocial.com.br
cdd.searchcube.com.sg
chat.missarkansas.org
c23111azqw.nigerias.io
apply.ansuraniphone.my
form.searchcube.com.sg
gcase.barrettamario.it
info.clickasuransi.com
view.onlinebotdemo.xyz
mainmenu.diddancing.com
83242573.actualizar.xyz
serviziaziendali.online
kodawariab736.skeep.it
91181264.your-access.one
form.sergiolimajr.com.br
type.opaulovieira.com.br
hunterbot.saleshunter.ai
aibot.angrybranding.co.uk
boyfriend-breakup.riku.ai
type.dericsoncalari.com.br
designguide.techyscouts.com
piazzatorre.barrettamario.it
onboarding.libertydreamcare.ie
agendamento.sergiolimajr.com.br
type.talitasouzamarques.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
personal-trainer.barrettamario.it
studiotecnicoimmobiliaremerelli.it
viewer-v2-alpha-typebot-io.vercel.app
preagendamento.sergiolimajr.com.br
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e03fe9f Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e03fe9f Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on e03fe9f Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e03fe9f Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

Please sign in to comment.