Commit 1eb8b65e authored by Michael Leu's avatar Michael Leu 🌿
Browse files

feat: custom stage build commands for static js

parent d48bdd75
Pipeline #119047 passed with stages
in 3 minutes and 37 seconds
......@@ -277,13 +277,12 @@ include:
```
This include assumes build, lint and test commands in your package.json.
`build` should export the build into `dist` folder.
If the production build needs a different command, set the variable `PROD_BUILD_COMMAND`:
`build` should export the build into `dist` folder. If the staging and/or production build needs a different command, set the variables `STAGE_BUILD_COMMAND` & `PROD_BUILD_COMMAND`:
```yaml
variables:
PROD_BUILD_COMMAND: "npm run ng build --prod=true"
STAGE_BUILD_COMMAND: "yarn build-stage"
PROD_BUILD_COMMAND: "yarn build-prod"
```
It will create a nginx docker image with a default config.
......
......@@ -14,6 +14,15 @@ docker-build:
before_script:
- ensureNginxDockerFile
# [STAGE|PROD]_BUILD_COMMAND support:
app-build-stage:
extends: .app-build-node
rules:
- if: $STAGE_BUILD_COMMAND && $CI_COMMIT_TAG && $STAGING_ENABLED == "true"
script:
- $STAGE_BUILD_COMMAND
app-build-prod:
extends: .app-build-node
rules:
......@@ -21,6 +30,16 @@ app-build-prod:
script:
- $PROD_BUILD_COMMAND
docker-build-stage:
extends: docker-build
rules:
- if: $STAGE_BUILD_COMMAND && $CI_COMMIT_TAG && $STAGING_ENABLED == "true"
needs:
- job: app-build-stage
artifacts: true
variables:
IMAGE_TAG: ${CI_COMMIT_SHA}-stage
docker-build-prod:
extends: docker-build
rules:
......@@ -31,6 +50,12 @@ docker-build-prod:
variables:
IMAGE_TAG: ${CI_COMMIT_SHA}-prod
stage-deploy:
extends: .stage-deploy
# ugly hack to keep the job name the same regardless if STAGE_BUILD_COMMAND is defined
before_script:
- test "$STAGE_BUILD_COMMAND" && export IMAGE_TAG="${CI_COMMIT_SHA}-stage"
prod-deploy:
extends: .prod-deploy
# ugly hack to keep the job name the same regardless if PROD_BUILD_COMMAND is defined
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment