Skip to content

Commit

Permalink
add code
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank Sinha committed Jun 3, 2018
0 parents commit fdc1870
Show file tree
Hide file tree
Showing 22 changed files with 1,336 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
stages:
- build
- validate
- deploy

variables:
CONTAINER_IMAGE: shashanksinha/php
CONTAINER_IMAGE_LATEST: ${CONTAINER_IMAGE}:${CI_PIPELINE_ID}
CI_REGISTRY: index.docker.io # container registry URL
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375 # required since we use dind


build:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- echo "FQDN is ${DB_SERVER}"
- echo "dbname is ${DB_NAME}"
- echo "username is ${DB_USERNAME}"
- echo "password is ${DB_PASSWORD}"
- sed -i -e "s/fqdn/${DB_SERVER}/g" app-code/config.php
- sed -i -e "s/dbname/${DB_NAME}/g" app-code/config.php
- sed -i -e "s/username/${DB_USERNAME}/g" app-code/config.php
- sed -i -e "s/password/${DB_PASSWORD}/g" app-code/config.php
- cat app-code/config.php

script:
- echo "Building Dockerfile-based application..."
- docker build -t ${CONTAINER_IMAGE_LATEST} .
- echo "username is $CI_REGISTRY_USER and password is $CI_REGISTRY_PASSWORD"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- echo "Pushing to the Container Registry..."
- docker push ${CONTAINER_IMAGE_LATEST}

validate:
stage: validate
image: docker:latest
script:
- echo "Run test cases"

deploy:
stage: deploy
image: linkyard/docker-helm
script:
- helm init --upgrade
- helm repo add stable https://kubernetes-charts.storage.googleapis.com
- helm upgrade --install php-app --namespace default --wait --set image.tag=${CI_PIPELINE_ID} --set replicaCount=2 helm-data/
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM shashanksinha/php
COPY app-code/ /app/
Empty file added README.md
Empty file.
Loading

0 comments on commit fdc1870

Please sign in to comment.