Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
punkdata committed Jun 12, 2021
1 parent 6f05a09 commit 8ab3bce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
46 changes: 26 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
version: 2.1
workflows:
build_test_deploy:
jobs:
- build_test
- deploy:
requires:
- build_test
orbs:
docker: circleci/[email protected]
jobs:
build_test:
docker:
- image: circleci/python:3.7
- image: circleci/python:3.9
steps:
- checkout
- run:
Expand All @@ -19,21 +14,32 @@ jobs:
- run:
name: Run Tests
command: ~/.local/bin/pytest
deploy:
build_push_docker_image:
docker:
- image: circleci/python:3.7
- image: circleci/python:3.9
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: false
- run:
name: Build and push Docker image
command: |
name: Build app binary
command: |
pip install --user --no-cache-dir -r requirements.txt
~/.local/bin/pyinstaller -F hello_world.py
echo 'export TAG=0.1.${CIRCLE_BUILD_NUM}' >> $BASH_ENV
echo 'export IMAGE_NAME=python-cicd-workshop' >> $BASH_ENV
source $BASH_ENV
docker build -t $DOCKER_LOGIN/$IMAGE_NAME -t $DOCKER_LOGIN/$IMAGE_NAME:$TAG .
echo $DOCKER_PWD | docker login -u $DOCKER_LOGIN --password-stdin
docker push $DOCKER_LOGIN/$IMAGE_NAME
- setup_remote_docker
- docker/check
- docker/build:
image: $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME
extra_build_args: "-t $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME"
tag: 0.1.<< pipeline.number >>
- docker/push:
image: $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME
tag: "latest"
- docker/push:
image: $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME
tag: "0.1.<< pipeline.number >>"
workflows:
test_build_deploy:
jobs:
- build_test
- build_push_docker_image:
requires:
- build_test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.9

RUN mkdir /opt/hello_world/
WORKDIR /opt/hello_world/
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Introduction to CI/CD Workshop

This repo hosts the codebase and tutorial for an Introductory CI/CD Workshop. The workshop is designed to demonstrate and explain how to implement a CI/CD pipeline into a codebase.

## Tutorial

The tutorial can be found in the `tutorial/` directory of this repo. The [icd_101_guide.md](tutorial/cicd_101_guide.md) file hosts the tutorial content for the hands on portion of this tutorial.
22 changes: 11 additions & 11 deletions terraform/google_cloud/main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
variable "project_name" {
type = "string"
type = string
default = "cicd-workshops"
}

variable "port_number" {
type = "string"
type = string
default = "5000"
}

variable "docker_declaration" {
type = "string"
type = string
# Change the image: string to match the docker image you want to use
default = "spec:\n containers:\n - name: test-docker\n image: 'ariv3ra/python-cicd-workshop'\n stdin: false\n tty: false\n restartPolicy: Always\n"
}

variable "boot_image_name" {
type = "string"
type = string
default = "projects/cos-cloud/global/images/cos-stable-69-10895-62-0"
}

Expand All @@ -25,22 +25,22 @@ data "google_compute_network" "default" {

# Specify the provider (GCP, AWS, Azure)
provider "google"{
credentials = "${file("cicd_demo_gcp_creds.json")}"
project = "${var.project_name}"
credentials = file("cicd_demo_gcp_creds.json")
project = var.project_name
region = "us-east1-b"
}

resource "google_compute_firewall" "http-5000" {
name = "http-5000"
network = "${data.google_compute_network.default.name}"
network = data.google_compute_network.default.name

allow {
protocol = "icmp"
}

allow {
protocol = "tcp"
ports = ["${var.port_number}"]
ports = [var.port_number]
}
}

Expand All @@ -55,13 +55,13 @@ resource "google_compute_instance" "default" {
boot_disk {
auto_delete = true
initialize_params {
image = "${var.boot_image_name}"
image = var.boot_image_name
type = "pd-standard"
}
}

metadata = {
gce-container-declaration = "${var.docker_declaration}"
gce-container-declaration = var.docker_declaration
}

labels = {
Expand All @@ -77,5 +77,5 @@ resource "google_compute_instance" "default" {
}

output "Public_IP_Address" {
value = "${google_compute_instance.default.network_interface.0.access_config.0.nat_ip}"
value = google_compute_instance.default.network_interface[0].access_config[0].nat_ip
}

0 comments on commit 8ab3bce

Please sign in to comment.