GitLab Runner: Best way to deploy to host system
Hello,
im currently hosting GitLab-EE and my the project-specific Runner on a Virtual Machine.
I’m using GitLab to Develop and Publish Projects using the above mentioned Runner.
Context
My current project involves storybook
I’m running npm run build-storybook
to create a static version of the storybook page. storybook-static
. I’m serving this folder using NGINX (also acts as reverse proxy for gitlab).
GitLab Runner is setup with docker executor.
Every Project has it’s own Runner on it’s own VM ! (I’m not the only one who uses the instance)
Main Question
Now the main question: GitLab Runner is installed on the same machine as the webserver. How can i easily copy artifacts, created by the Runner to the webroot? (var/www/...
)
Current Pipeline: Test -> Coverage -> Build -> Deploy
.
Can i access the Filesystem directly from the CI/CD Pipeline? or do i have to copy it using scp or tftp or some other tool ?
As far as i understand, i cannot access the filesystem directly, because everything is built inside a docker container. Right ?
.gitlab-ci.yml
:
stages:
- test
- coverage
- build
- deploy
Component Tests:
image: node:latest
stage: test
when: manual
script:
- npm ci
- npm run prettier
- npm run test-components
allow_failure: false
only:
- main
- production
- */production-deployment
- merge_requests
Code Coverage:
image: node:latest
stage: coverage
script:
- npm ci
- npm run prettier
- npm run coverage
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
artifacts:
reports:
junit: junit.xml
only:
- production
- merge_requests
Build Storybook Production:
image: node:latest
stage: build
dependencies:
- Component Tests
- Code Coverage
script:
- npm ci
- npm run prettier
- npm run build-storybook
artifacts:
paths:
- storybook-static
expire_in: 30min
only:
- main
- production
- */production-deployment
- merge_requests
Deploy Production:
stage: deploy
image: ubuntu:20.04
dependencies:
- Component Tests
- Build Storybook Production
script:
- apt-get -y update
- apt-get -y upgrade
- apt-get install -y sshpass
- rm -f ~/.ssh/known_hosts
- sshpass -p "$CI_DEPLOYMENT_PASSWORD" scp -rv ./storybook-static/* deployment@<removed>:/var/www/<removed>-storybook
only:
- production
- */production-deployment