@toptal/davinci-ci 1.14.6-alpha-feature-comm-833-reusing-graphql-fragments-9260db4c.20 → 1.14.6-alpha-feature-comm-833-reusing-graphql-fragments-bc6ed661.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/package.json +3 -3
  2. package/CHANGELOG.md +0 -970
  3. package/LICENSE.MD +0 -4
  4. package/README.md +0 -83
  5. package/bin/davinci-ci.js +0 -8
  6. package/src/commands/danger.js +0 -67
  7. package/src/configs/danger/conventional-commits/dangerfile.js +0 -17
  8. package/src/configs/danger/conventional-commits/plugins/conventional-commits/index.js +0 -52
  9. package/src/configs/danger/conventional-commits/plugins/conventional-pr-title/index.js +0 -53
  10. package/src/configs/danger/conventional-commits/plugins/index.js +0 -7
  11. package/src/configs/danger/plugins/empty-assignee.js +0 -24
  12. package/src/configs/danger/toptal/config.js +0 -30
  13. package/src/configs/danger/toptal/dangerfile.js +0 -17
  14. package/src/configs/danger/toptal/plugins/index.js +0 -7
  15. package/src/configs/danger/toptal/plugins/toptal-commits/index.js +0 -73
  16. package/src/configs/danger/toptal/plugins/toptal-pr-title/index.js +0 -62
  17. package/src/configs/docker/Dockerfile +0 -30
  18. package/src/configs/docker/Dockerfile.gha-deploy +0 -33
  19. package/src/configs/docker/Dockerfile.release +0 -28
  20. package/src/configs/docker/Dockerfile.storybook +0 -20
  21. package/src/configs/docker/env-runtime.entrypoint.sh +0 -47
  22. package/src/configs/docker/nginx-vhost-storybook.conf +0 -20
  23. package/src/configs/docker/nginx-vhost.conf +0 -18
  24. package/src/configs/jobs/build-image/Jenkinsfile +0 -142
  25. package/src/configs/jobs/build-image/config.xml +0 -119
  26. package/src/configs/jobs/build-release-image/Jenkinsfile +0 -154
  27. package/src/configs/jobs/build-release-image/config.xml +0 -102
  28. package/src/configs/jobs/consumer-contracts-verify/Jenkinsfile +0 -117
  29. package/src/configs/jobs/consumer-contracts-verify/config.xml +0 -114
  30. package/src/configs/jobs/deploy/config.xml +0 -107
  31. package/src/configs/jobs/deploy-helm-run/Jenkinsfile +0 -159
  32. package/src/configs/jobs/deploy-helm-run/config.xml +0 -107
  33. package/src/configs/jobs/deploy-helm-run-trigger/Jenkinsfile +0 -200
  34. package/src/configs/jobs/master-main/Jenkinsfile +0 -460
  35. package/src/configs/jobs/master-main/config.xml +0 -119
  36. package/src/configs/jobs/pr-tests/Jenkinsfile +0 -407
  37. package/src/configs/jobs/pr-tests/config.xml +0 -134
  38. package/src/configs/jobs/publish-alpha-package/Jenkinsfile +0 -189
  39. package/src/configs/jobs/publish-alpha-package/config.xml +0 -136
  40. package/src/configs/jobs/temploy-helm-run/Jenkinsfile +0 -141
  41. package/src/configs/jobs/temploy-helm-run/config.xml +0 -97
  42. package/src/index.js +0 -17
package/LICENSE.MD DELETED
@@ -1,4 +0,0 @@
1
- /* Copyright (C) Toptal LLC - All Rights Reserved
2
- * Unauthorized copying of this file, via any medium is strictly prohibited
3
- * Proprietary and confidential
4
- */
package/README.md DELETED
@@ -1,83 +0,0 @@
1
- # `@toptal/davinci-ci`
2
-
3
- Holds Jenkins jobs definitions and Docker files supporting frontend applications.
4
-
5
- ## Demo
6
-
7
- Watch [this video](https://drive.google.com/file/d/1C5ApkATYCXZ8kTn2LeG5FkM4AveLxAd8/view?usp=sharing) for a demo of how to set up a davinci-ci Jenkins jobs for a project or check the [How to start a new application](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/1120831396/How+to+start+a+new+application) guide.
8
-
9
- ## Installation
10
-
11
- Use it by installing `yarn add @toptal/davinci-ci` in your project.
12
-
13
- ## Usage
14
-
15
- ### Commands
16
-
17
- - `davinci-ci danger` - checks if the PR title and and commit messages comply with [Toptal's standards](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality)
18
-
19
- - `davinci-ci danger --conventionalCommits` - checks if the PR title and and commit messages comply with [ConventionalCommits](https://www.conventionalcommits.org/en/v1.0.0/)
20
-
21
- To check commit message quality locally just add `--local` argument
22
-
23
- `davinci-ci danger --local`
24
-
25
- Using husky, you can check the commit message before pushing files changes.
26
-
27
- ```js
28
- "husky": {
29
- "hooks": {
30
- "pre-push": "yarn davinci-ci danger --local"
31
- }
32
- },
33
- ```
34
-
35
- ### Configuration
36
-
37
- You can specify which scenarios you want to be performed both for PR and master branch updates by creating a davinci.yaml file in the root of your project with the following structure.
38
-
39
- (by default each config option is set to `false`)
40
-
41
- ```yaml
42
- pr:
43
- contract_testing: false
44
-
45
- master:
46
- publish_as_package: false
47
- deploy_staging: false
48
- deploy_storybook_staging: false
49
- deploy: false
50
- conventional_commits: false # danger check will require each commit to follow convential commits
51
- require_assignee: false # danger check will require each PR to have assignee
52
- require_assignee_whitelist: ['dependabot-preview[bot]', 'dependabot[bot]']
53
-
54
- # Customize Slack channel where the notifications will get posted
55
- slack_channel: 'custom-slack-channel'
56
- is_progressive_web_app: true
57
- ```
58
-
59
- ### Commands you can use in GitHub PRs
60
-
61
- `@toptal-bot run tests` - to re-run `pr-tests` job
62
-
63
- `@toptal-bot run package:alpha-release` - to run `publish-alpha-package` job, which is publishing alpha release of the package to npm (temploy for npm package)
64
-
65
- ### How to setup cypress in CI
66
-
67
- In order to enable cypress tests on CI jobs (both pr-tests and master-main) enable it on your project `davinci.yaml` file, like in the example below:
68
-
69
- ```yaml
70
- pr:
71
- cypress: true
72
- master:
73
- cypress: true
74
- ```
75
-
76
- If you have it set as false or if this config is not present in your project `davinci.yaml` file, cypress step will be skipped.
77
-
78
- ### IDE Tooling
79
-
80
- This package can be used directly in your IDE through these extensions
81
-
82
- - [IntelliJ Suite (WebStorm, RubyMine, IDEA)](https://github.com/zaguiini/intellij-davinci-plugin)
83
- - [VSCode](https://github.com/borisyordanov/vscode-supercharge-react)
package/bin/davinci-ci.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cliEngine = require('@toptal/davinci-cli-shared')
4
-
5
- const { commands } = require('../src')
6
-
7
- cliEngine.loadCommands(commands, 'davinci-ci')
8
- cliEngine.bootstrap()
@@ -1,67 +0,0 @@
1
- const {
2
- davinciProjectConfig,
3
- runSync,
4
- print,
5
- convertToCLIParameters,
6
- files,
7
- } = require('@toptal/davinci-cli-shared')
8
-
9
- const commandOptions = [
10
- {
11
- label: 'check only, without fixing the code',
12
- name: '--check',
13
- },
14
- {
15
- label: 'checks commit message quality locally',
16
- name: '--local',
17
- },
18
- {
19
- label: 'specify custom danger file',
20
- name: '--dangerfile <dangerfile>',
21
- },
22
- ]
23
-
24
- const dangerCommand = ({ options }) => {
25
- print.green('Running danger check...')
26
-
27
- const { local, dangerfile, ...rest } = options
28
-
29
- const conventionalCommitsDangerfilePath = files.getPackageFilePath(
30
- '@toptal/davinci-ci',
31
- 'src/configs/danger/conventional-commits/dangerfile.js'
32
- )
33
- const toptalCommitsDangerfilePath = files.getPackageFilePath(
34
- '@toptal/davinci-ci',
35
- 'src/configs/danger/toptal/dangerfile.js'
36
- )
37
-
38
- let dangerfilePath = dangerfile
39
-
40
- if (!dangerfilePath) {
41
- dangerfilePath = davinciProjectConfig.master.conventionalCommits
42
- ? conventionalCommitsDangerfilePath
43
- : toptalCommitsDangerfilePath
44
- }
45
-
46
- runSync(
47
- 'yarn',
48
- [
49
- 'danger',
50
- local ? 'local' : 'ci',
51
- local ? '--failOnErrors' : undefined,
52
- '--dangerfile',
53
- `${dangerfilePath}`,
54
- ...convertToCLIParameters(rest),
55
- ].filter(Boolean)
56
- )
57
- }
58
-
59
- const dangerCommandCreator = {
60
- action: dangerCommand,
61
- allowUnknownOptions: true,
62
- command: 'danger',
63
- description: 'Run danger check',
64
- options: commandOptions,
65
- }
66
-
67
- module.exports = dangerCommandCreator
@@ -1,17 +0,0 @@
1
- const { schedule } = require('danger')
2
- const { davinciProjectConfig } = require('@toptal/davinci-cli-shared')
3
-
4
- const { conventionalCommits } = require('./plugins/conventional-commits')
5
- const { conventionalPRTitle } = require('./plugins/conventional-pr-title')
6
- const { checkAssigneeExist } = require('../plugins/empty-assignee')
7
-
8
- schedule(conventionalCommits)
9
- schedule(conventionalPRTitle)
10
-
11
- const {
12
- master: { requireAssignee },
13
- } = davinciProjectConfig
14
-
15
- if (requireAssignee) {
16
- schedule(checkAssigneeExist)
17
- }
@@ -1,52 +0,0 @@
1
- /* globals danger, fail */
2
- /* eslint-disable import/no-extraneous-dependencies */
3
- const { default: load } = require('@commitlint/load')
4
- const { default: lint } = require('@commitlint/lint')
5
- /* eslint-enable */
6
- const table = require('markdown-table')
7
-
8
- const { WHITELISTED_USERS } = require('../../../toptal/config')
9
-
10
- const conventionalCommits = async () => {
11
- if (
12
- danger.github &&
13
- WHITELISTED_USERS.includes(danger.github.pr.user.login)
14
- ) {
15
- return
16
- }
17
-
18
- const { commits } = danger.git
19
- const { rules, parserPreset } = await load({
20
- extends: ['@commitlint/config-conventional'],
21
- })
22
-
23
- commits.forEach(async commit => {
24
- const result = await lint(
25
- commit.message,
26
- rules,
27
- parserPreset ? { parserOpts: parserPreset.parserOpts } : {}
28
- )
29
-
30
- if (!result.valid) {
31
- if (result.errors.length > 0) {
32
- let message = `The commit - ${commit.sha.trim()} doesn't conform the conventional commit guidelines. \n\n**Errors**:\n\n`
33
-
34
- message += table([
35
- ['Message'],
36
- ...result.errors.map(error => [error.message]),
37
- ])
38
-
39
- message +=
40
- '\n\n💡 For a guidance on how to fix this problem please refer to [https://www.conventionalcommits.org](https://www.conventionalcommits.org)'
41
- message +=
42
- '\n\n💡 Or you can check our [documentation](https://github.com/toptal/picasso/blob/master/docs/contribution/github-workflow.md#general-commit-message-pattern)'
43
-
44
- fail(message)
45
- }
46
- }
47
- })
48
- }
49
-
50
- module.exports = {
51
- conventionalCommits,
52
- }
@@ -1,53 +0,0 @@
1
- /// <reference types="danger" />
2
- /* globals danger, fail */
3
- /* eslint-disable import/no-extraneous-dependencies */
4
- const { default: load } = require('@commitlint/load')
5
- const { default: lint } = require('@commitlint/lint')
6
- /* eslint-enable */
7
- const table = require('markdown-table')
8
-
9
- const { WHITELISTED_USERS } = require('../../../toptal/config')
10
-
11
- const conventionalPRTitle = async () => {
12
- if (!danger.github) {
13
- return
14
- }
15
-
16
- if (WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
17
- return
18
- }
19
-
20
- const { rules, parserPreset } = await load({
21
- extends: ['@commitlint/config-conventional'],
22
- })
23
- const { title } = danger.github.pr
24
-
25
- const result = await lint(
26
- title,
27
- rules,
28
- parserPreset ? { parserOpts: parserPreset.parserOpts } : {}
29
- )
30
-
31
- if (!result.valid) {
32
- if (result.errors.length > 0) {
33
- let message =
34
- "PR title doesn't conform the conventional commit guidelines. \n\n**Errors**:\n\n"
35
-
36
- message += table([
37
- ['Message'],
38
- ...result.errors.map(error => [error.message]),
39
- ])
40
-
41
- message +=
42
- '\n\n💡 For a guidance on how to fix this problem please refer to [https://www.conventionalcommits.org](https://www.conventionalcommits.org)'
43
- message +=
44
- '\n\n💡 Or you can check our [documentation](https://github.com/toptal/picasso/blob/master/docs/contribution/github-workflow.md#general-commit-message-pattern)'
45
-
46
- fail(message)
47
- }
48
- }
49
- }
50
-
51
- module.exports = {
52
- conventionalPRTitle,
53
- }
@@ -1,7 +0,0 @@
1
- const { conventionalCommits } = require('./conventional-commits')
2
- const { conventionalPRTitle } = require('./conventional-pr-title')
3
-
4
- module.exports = {
5
- conventionalCommits,
6
- conventionalPRTitle,
7
- }
@@ -1,24 +0,0 @@
1
- /// <reference types="danger" />
2
- /* globals danger, fail */
3
- const { davinciProjectConfig } = require('@toptal/davinci-cli-shared')
4
-
5
- const {
6
- master: { requireAssigneeWhiteList = [] },
7
- } = davinciProjectConfig
8
-
9
- const WHITELISTED_USERS = requireAssigneeWhiteList
10
- const checkAssigneeExist = () => {
11
- const isLocalRun = !danger.github
12
-
13
- if (isLocalRun || WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
14
- return
15
- }
16
-
17
- if (!danger.github.pr.assignee || danger.github.pr.assignees.length === 0) {
18
- fail('Please assign someone to this PR before merging.')
19
- }
20
- }
21
-
22
- module.exports = {
23
- checkAssigneeExist,
24
- }
@@ -1,30 +0,0 @@
1
- const WHITELISTED_USERS = [
2
- 'dependabot-preview[bot]',
3
- 'dependabot[bot]',
4
- 'toptal-devbot',
5
- ]
6
- const VALID_PR_CODE_REGEX = /\[[A-Z]{1,5}-.*]\s/
7
- // Valid commit titles:
8
- // "Regular commit message"
9
- // "Commit with sentence. But does not end with a full-stop"
10
- // "[FOO-1234] Commit with prefix"
11
- // "[FOO] Prefix numbers can be omitted"
12
- // "[FOO][BAR] Prefixes can couple"
13
- const VALID_COMMIT_TITLE_REGEX = /^((\[[A-Z]+(-\d+)?])+ )?[A-Z]\w[^\n]*[^.]$/
14
- const MAX_COMMIT_LINE_LENGTH = 79
15
- const ENGINEERING_DOCS_LINK =
16
- 'https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality'
17
-
18
- const DEFAULT_PR_TITLE_ERROR_MESSAGE = `The pull request title doesn't conform to Toptal's engineering practices. For guidance on how to fix this problem please refer [here](${ENGINEERING_DOCS_LINK})`
19
- const MISSING_TICKET_CODE_ERROR_MESSAGE =
20
- "The pull request title is missing a Jira issue code. Correct format '[ASD-123] Add a cool feature'. If you're working without a Jira issue then add a 'no-jira' label to your pull request."
21
-
22
- module.exports = {
23
- DEFAULT_PR_TITLE_ERROR_MESSAGE,
24
- ENGINEERING_DOCS_LINK,
25
- MAX_COMMIT_LINE_LENGTH,
26
- MISSING_TICKET_CODE_ERROR_MESSAGE,
27
- VALID_COMMIT_TITLE_REGEX,
28
- VALID_PR_CODE_REGEX,
29
- WHITELISTED_USERS,
30
- }
@@ -1,17 +0,0 @@
1
- const { schedule } = require('danger')
2
- const { davinciProjectConfig } = require('@toptal/davinci-cli-shared')
3
-
4
- const { toptalCommits } = require('./plugins/toptal-commits')
5
- const { toptalPRTitle } = require('./plugins/toptal-pr-title')
6
- const { checkAssigneeExist } = require('../plugins/empty-assignee')
7
-
8
- schedule(toptalCommits)
9
- schedule(toptalPRTitle)
10
-
11
- const {
12
- master: { requireAssignee },
13
- } = davinciProjectConfig
14
-
15
- if (requireAssignee) {
16
- schedule(checkAssigneeExist)
17
- }
@@ -1,7 +0,0 @@
1
- const { toptalCommits } = require('./toptal-commits')
2
- const { toptalPRTitle } = require('./toptal-pr-title')
3
-
4
- module.exports = {
5
- toptalCommits,
6
- toptalPRTitle,
7
- }
@@ -1,73 +0,0 @@
1
- /* globals danger, fail */
2
- const {
3
- MAX_COMMIT_LINE_LENGTH,
4
- VALID_COMMIT_TITLE_REGEX,
5
- WHITELISTED_USERS,
6
- } = require('../../config')
7
-
8
- const validateCommitMessage = message => {
9
- const errors = []
10
- const [title = '', body = ''] = message.split(/\n\n/)
11
- const bodyLines = body.split(/\n/)
12
- const isTitleFormatValid = VALID_COMMIT_TITLE_REGEX.test(title)
13
- const isTitleLengthValid = title.length <= MAX_COMMIT_LINE_LENGTH
14
- const isBodyLinesLengthValid = bodyLines.every(
15
- line => line.length <= MAX_COMMIT_LINE_LENGTH
16
- )
17
-
18
- if (!isTitleFormatValid) {
19
- errors.push(`- format of commit title is not correct ([read more](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality)):
20
- - Title should start with capital letter
21
- - Title should not end with a full-stop (i.e .)\n
22
- Example of a valid commit title:
23
- - Regular commit message
24
- - [FOO-1234] Commit with prefix
25
- - [FOO][BAR] Coupled prefixes`)
26
- }
27
-
28
- if (!isTitleLengthValid) {
29
- errors.push(
30
- `- title is too long (max ${MAX_COMMIT_LINE_LENGTH} characters)`
31
- )
32
- }
33
-
34
- if (!isBodyLinesLengthValid) {
35
- errors.push(
36
- `- body lines must not exceed ${MAX_COMMIT_LINE_LENGTH} characters`
37
- )
38
- }
39
-
40
- return errors
41
- }
42
-
43
- const toptalCommits = () => {
44
- if (
45
- danger.github &&
46
- WHITELISTED_USERS.includes(danger.github.pr.user.login)
47
- ) {
48
- return
49
- }
50
-
51
- const { commits } = danger.git
52
-
53
- commits.forEach(commit => {
54
- if (commit.author && WHITELISTED_USERS.includes(commit.author.name)) {
55
- return
56
- }
57
-
58
- const validationErrors = validateCommitMessage(commit.message)
59
-
60
- if (validationErrors.length) {
61
- fail(
62
- [
63
- `Commit ${commit.sha.trim()} does not meet requirements of [Commit Message Quality](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality):`,
64
- ...validationErrors,
65
- ].join('\n')
66
- )
67
- }
68
- })
69
- }
70
-
71
- module.exports = {
72
- toptalCommits,
73
- }
@@ -1,62 +0,0 @@
1
- /* globals danger, fail */
2
- const {
3
- VALID_COMMIT_TITLE_REGEX,
4
- VALID_PR_CODE_REGEX,
5
- WHITELISTED_USERS,
6
- DEFAULT_PR_TITLE_ERROR_MESSAGE,
7
- MISSING_TICKET_CODE_ERROR_MESSAGE,
8
- } = require('../../config')
9
-
10
- const getTicketCode = text => {
11
- const ticketCode = text.match(VALID_PR_CODE_REGEX)
12
-
13
- if (!ticketCode) {
14
- return
15
- }
16
-
17
- return ticketCode[0]
18
- }
19
-
20
- const showError = (error = DEFAULT_PR_TITLE_ERROR_MESSAGE) => {
21
- fail(error)
22
- }
23
-
24
- const toptalPRTitle = () => {
25
- if (!danger.github) {
26
- return
27
- }
28
-
29
- if (WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
30
- return
31
- }
32
-
33
- const { title } = danger.github.pr
34
- const labelNames = danger.github.issue.labels.map(({ name }) => name)
35
-
36
- const ticketCode = getTicketCode(title)
37
-
38
- if (!ticketCode && !labelNames.includes('no-jira')) {
39
- showError(MISSING_TICKET_CODE_ERROR_MESSAGE)
40
-
41
- return
42
- }
43
-
44
- const splitTitle = title.split(ticketCode)
45
-
46
- if (!splitTitle.length) {
47
- showError()
48
-
49
- return
50
- }
51
-
52
- const titleText = splitTitle[splitTitle.length - 1]
53
- const isTitleFormatValid = VALID_COMMIT_TITLE_REGEX.test(titleText)
54
-
55
- if (!isTitleFormatValid) {
56
- showError()
57
- }
58
- }
59
-
60
- module.exports = {
61
- toptalPRTitle,
62
- }
@@ -1,30 +0,0 @@
1
- FROM node:14
2
-
3
- ARG NPM_TOKEN
4
- ENV NPM_TOKEN ${NPM_TOKEN}
5
-
6
- # Change default 'node' user id to match jenkins CI user id
7
- # so when we will be running container from CI it would have
8
- # all necessary rights for npm/yarn publish
9
- RUN groupmod -g 469 node && usermod -u 469 -g 469 node
10
-
11
- WORKDIR /app
12
- RUN chown -R node /app
13
-
14
- USER node
15
-
16
- # Add github.com to known ssh hosts
17
- RUN mkdir ~/.ssh
18
- RUN ssh-keyscan github.com >> ~/.ssh/known_hosts
19
-
20
- # Needs to be updated for publishing package to npm
21
- RUN printf '//registry.npmjs.org/:_authToken=${NPM_TOKEN}\nalways-auth=true\n' > .npmrc
22
- RUN yarn config set registry https://registry.npmjs.org
23
-
24
- # Enables layer caching
25
- COPY --chown=node:node package.json yarn.lock ./
26
- RUN yarn install --frozen-lockfile --network-timeout 120000
27
-
28
- COPY --chown=node:node . /app
29
-
30
- RUN yarn build
@@ -1,33 +0,0 @@
1
- # Create the image with Nginx environment.
2
- FROM nginx:alpine
3
-
4
- # Copy results from the dist folder to the image.
5
- ARG DIST_FOLDER
6
- RUN [ -z "$DIST_FOLDER" ] && echo "DIST_FOLDER is required" && exit 1 || true
7
- COPY $DIST_FOLDER /usr/share/nginx/html
8
-
9
- # Remove source maps from the production build
10
- RUN find /usr/share/nginx/html -name "*.map" -type f -delete
11
-
12
- # Copy the entrypoint.
13
- ARG ENV_RUNTIME_ENTRYPOINT
14
- RUN [ -z "$ENV_RUNTIME_ENTRYPOINT" ] && echo "ENV_RUNTIME_ENTRYPOINT is required" && exit 1 || true
15
- COPY $ENV_RUNTIME_ENTRYPOINT /usr/local/bin/env-runtime.entrypoint.sh
16
- RUN chmod +x /usr/local/bin/env-runtime.entrypoint.sh
17
-
18
- # version is used in build process, so the value won't be available here otherwise
19
- ARG VERSION
20
- RUN [ -z "$VERSION" ] && echo "VERSION is required" && exit 1 || true
21
- ENV DAVINCI_RELEASE_VERSION $VERSION
22
-
23
- RUN echo $VERSION > /usr/share/nginx/html/REVISION.txt
24
-
25
- # Copy configuration file for Nginx and replace the default one.
26
- ARG NGINX_CONFIG
27
- RUN [ -z "$NGINX_CONFIG" ] && echo "NGINX_CONFIG is required" && exit 1 || true
28
- COPY $NGINX_CONFIG /etc/nginx/conf.d/default.conf
29
-
30
- # Entry point to provide Run Time Environment Variables for the App.
31
- ENTRYPOINT ["/usr/local/bin/env-runtime.entrypoint.sh"]
32
-
33
- CMD ["nginx", "-g", "daemon off;"]
@@ -1,28 +0,0 @@
1
- ARG VERSION
2
- ARG REPO_NAME
3
-
4
- FROM gcr.io/toptal-hub/${REPO_NAME}:${VERSION} as builder
5
-
6
- FROM nginx:alpine
7
-
8
- ARG ENV_RUNTIME_ENTRYPOINT
9
-
10
- COPY --from=builder /app/dist /usr/share/nginx/html
11
- COPY --from=builder /app/node_modules/@toptal/davinci-ci/src/configs/docker/nginx-vhost.conf /etc/nginx/conf.d/default.conf
12
-
13
- # Remove source maps from the production build
14
- RUN find /usr/share/nginx/html -name "*.map" -type f -delete
15
-
16
- # Copy the entrypoint to prepare env variables
17
- # example davinci/packages/ci/scr/configs/docker/env-runtime.entrypoint.sh
18
- COPY ${ENV_RUNTIME_ENTRYPOINT} /usr/local/bin/env-runtime.entrypoint.sh
19
-
20
- # version is used in build process, so the value won't be available here otherwise
21
- ARG VERSION
22
- ENV DAVINCI_RELEASE_VERSION $VERSION
23
-
24
- RUN echo $VERSION > /usr/share/nginx/html/REVISION.txt
25
-
26
- ENTRYPOINT ["/usr/local/bin/env-runtime.entrypoint.sh"]
27
-
28
- CMD ["nginx", "-g", "daemon off;"]
@@ -1,20 +0,0 @@
1
- # Create the image with Nginx environment.
2
- FROM nginx:alpine
3
-
4
- # Copy results from the dist folder to the image.
5
- ARG DIST_FOLDER
6
- RUN [ -z "$DIST_FOLDER" ] && echo "DIST_FOLDER is required" && exit 1 || true
7
- COPY $DIST_FOLDER /usr/share/nginx/html/storybook
8
-
9
- # version is used in build process, so the value won't be available here otherwise
10
- ARG VERSION
11
- RUN [ -z "$VERSION" ] && echo "VERSION is required" && exit 1 || true
12
-
13
- RUN echo $VERSION > /usr/share/nginx/html/REVISION.txt
14
-
15
- # Copy configuration file for Nginx and replace the default one.
16
- ARG NGINX_CONFIG
17
- RUN [ -z "$NGINX_CONFIG" ] && echo "NGINX_CONFIG is required" && exit 1 || true
18
- COPY $NGINX_CONFIG /etc/nginx/conf.d/default.conf
19
-
20
- CMD ["nginx", "-g", "daemon off;"]
@@ -1,47 +0,0 @@
1
- #!/bin/sh -e
2
-
3
- # This bash script takes required Environment Variables of current process
4
- # and put them into `index.html` file which is an entry-point of the application.
5
- # By this way we provide run time variables to a precompiled JS code.
6
-
7
- # This is how a place which contains `run time` variables may look in `index.html`
8
- #
9
- # window.TP = {
10
- # env: '%REACT_APP_ENV_NAME%',
11
- # graphql_url: '%REACT_APP_GRAPHQL_URI%'
12
- # }
13
-
14
- # keep in sync with index.html
15
- VARS_PREFIX="DAVINCI_"
16
- INDEX_FILE="/usr/share/nginx/html/index.html"
17
-
18
- VARS="$(env | grep $VARS_PREFIX | awk -F = '{print $1}')"
19
-
20
- # trim whitespaces
21
- REQUIRED_VARS="$(echo "$VARS" | xargs -n1 | sed 's/^//g')"
22
-
23
- # trim whitespaces and prepend $ to every var above
24
- ENVSUBST_KNOWN_VARS="$(echo "$VARS" | xargs -n1 | sed 's/^/\$/g')"
25
-
26
- # replace all the placeholders %VARIABLE_NAME% with the actual value of the variable
27
- for placeholder in $REQUIRED_VARS
28
- do
29
- value=`printenv "$placeholder"`
30
- # any character after 's' in sed is used as a separator
31
- # https://stackoverflow.com/a/16790877/1611414
32
- sed -i "s|%${placeholder}%|$value|g" $INDEX_FILE
33
- done
34
-
35
- MISSING_VARS="$(cat $INDEX_FILE | grep "%$VARS_PREFIX.*%" | sed 's/.*%\(.*\)%.*/\1/g')"
36
-
37
- if [ -n "$MISSING_VARS" ]; then
38
- for placeholder in $MISSING_VARS
39
- do
40
- if ! printenv "$placeholder" > /dev/null; then
41
- echo "Variable '$placeholder' is not set. Exiting..."
42
- exit 1
43
- fi
44
- done
45
- fi
46
-
47
- exec "$@"