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: ...@@ -277,13 +277,12 @@ include:
``` ```
This include assumes build, lint and test commands in your package.json. This include assumes build, lint and test commands in your package.json.
`build` should export the build into `dist` folder. `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`:
If the production build needs a different command, set the variable `PROD_BUILD_COMMAND`:
```yaml ```yaml
variables: 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. It will create a nginx docker image with a default config.
......
...@@ -14,6 +14,15 @@ docker-build: ...@@ -14,6 +14,15 @@ docker-build:
before_script: before_script:
- ensureNginxDockerFile - 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: app-build-prod:
extends: .app-build-node extends: .app-build-node
rules: rules:
...@@ -21,6 +30,16 @@ app-build-prod: ...@@ -21,6 +30,16 @@ app-build-prod:
script: script:
- $PROD_BUILD_COMMAND - $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: docker-build-prod:
extends: docker-build extends: docker-build
rules: rules:
...@@ -31,6 +50,12 @@ docker-build-prod: ...@@ -31,6 +50,12 @@ docker-build-prod:
variables: variables:
IMAGE_TAG: ${CI_COMMIT_SHA}-prod 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: prod-deploy:
extends: .prod-deploy extends: .prod-deploy
# ugly hack to keep the job name the same regardless if PROD_BUILD_COMMAND is defined # 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