Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jlenon7/gitlab-deploy
🐳 A docker image to use inside Gitlab CI
https://github.com/jlenon7/gitlab-deploy
Last synced: 9 days ago
JSON representation
🐳 A docker image to use inside Gitlab CI
- Host: GitHub
- URL: https://github.com/jlenon7/gitlab-deploy
- Owner: jlenon7
- License: mit
- Created: 2021-11-09T11:24:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-18T23:38:42.000Z (over 2 years ago)
- Last Synced: 2024-10-05T23:42:02.591Z (3 months ago)
- Language: Dockerfile
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gitlab Deploy 🐳
> A docker image to use inside Gitlab CI pipelines
A simple docker image to help in your pipelines, `gitlab-deploy` is based in a `ubuntu` image and comes with `curl, make, zip, awscli, nvm, npm, nodejs, kubectl, helm and templating`.
Feel free to make a `pull request` to add more content to this image.## Adding more content to this image
> Gitlab CI uses DIND to execute the steps from the pipeline. If you want to add more content to the image, always remember that your command should exist in the interactive mode to work inside the pipeline
```yaml
# You can find this step inside ./.gitlab-ci.yml file# This is the actual CI pipeline of this project and runs only on new merge_request
Build and test the image commands:
image: docker:latest
stage: test
script:
- docker build -t test-gitlab-deploy .
- docker run -i test-gitlab-deploy aws help
- docker run -i test-gitlab-deploy curl --help
- docker run -i test-gitlab-deploy zip -v
- docker run -i test-gitlab-deploy make -v
- docker run -i test-gitlab-deploy npm -v
- docker run -i test-gitlab-deploy node -v
- docker run -i test-gitlab-deploy templating -v
- docker run -i test-gitlab-deploy helm
- docker run -i test-gitlab-deploy kubectl
- docker run -i test-gitlab-deploy /bin/bash -c "source /usr/local/bin/nvm/nvm.sh && nvm -v"
# Add your command over here. Example -> docker run -i test-gitlab-deploy javac
only:
- merge_requests
```## Pipeline Example
> A .gitlab-ci.yml file as example
```yaml
services:
- docker:18.09-dindvariables:
IMAGE_LATEST: nickname-organization/your-image-name-here:latest
IMAGE_TAG: nickname-organization/your-image-name-here:$CI_COMMIT_SHAstages:
- test
- build
- deployVerify lint and run tests:
image: node:16.13.0
stage: test
services:
- redis:latest
- postgres:latest
variables:
POSTGRES_DB: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "root"
DATABASE_URL_TESTING: "postgresql://postgres:root@postgres:5432/postgres?schema=public"
script:
- cp ./manifest/.env.ci .env.ci
- npm install --silent
- npm run lint:fix
- npm run test:ci
only:
- merge_requestsBuild and push image to Dockerhub:
image: docker:latest
stage: build
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker pull $IMAGE_LATEST || true
- docker build --cache-from $IMAGE_LATEST -t $IMAGE_TAG -t $IMAGE_LATEST .
- docker push $IMAGE_TAG
- docker push $IMAGE_LATEST
only:
- mainDeploy image to K8S Cluster:
image: jlenon7/gitlab-deploy:latest
stage: deploy
script:
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set region $AWS_DEFAULT_REGION
- aws eks --region $AWS_DEFAULT_REGION update-kubeconfig --name eks-$AWS_DEFAULT_REGION-production
- templating generate ./manifest/templates --set IMAGE_TAG=$IMAGE_TAG
- kubectl apply -f ./manifest/config-map.yml -f ./manifest/deployment.yml
needs: ["Build and push image to Dockerhub"]
only:
- main
```## Warning under nvm CLI
> To use nvm inside your pipelines you will need to use /bin/bash and source nvm.sh first
```yaml
Example:
image: jlenon7/gitlab-deploy:latest
stage: deploy
script:
# Install node 14.2 version and reinstall all global packages from version 16.2
- /bin/bash -c "source /usr/local/bin/nvm/nvm.sh && nvm install 14.2.0 && nvm reinstall-packages 16.2.0"
only:
- main
```---
Made with 🖤 by [jlenon7](https://github.com/jlenon7) 👋