Coder Social home page Coder Social logo

djanga's Introduction

DjangaI!

Use this humble repository to familiarize yourself with basic Codefresh functionality once you’ve got the development environment set up. asd This project uses Python Django to start a simple web application on port 8000.

Setting up the basic build

  1. Fork this repository to your own github user.

  2. Login to your local Codefresh instance with your github account.

  3. Add a new project and select the forked Djanga repository with the default master branch.

  4. Select to use Djanga’s own Dockerfile then click the SKIP & CREATE button.

  5. Once the build is created click CLOSE & BUILD to start a new build of the project.

Now that the build has initialized, let’s return to the build settings for some

Unit testing

  1. In the Unit Test Script section enter:

    python -m unittest composeexample.utils
  2. Click Save and build (not Launch!) the project again.

  3. One very simple test should fail. Fix this test and commit it, and a new build should automatically start (github webhooks, baby!).

So the unit tests are running and the build has completed. It’s time to

Push to Docker Hub

Back in the settings, under Docker Registry:

  1. Select Docker Hub.

  2. Enter your credentials.

  3. Check Push image to docker registry.

  4. Click Save and build the project again.

Now your image is in the cloud and you’re a star! Let’s extend our testing. First we’ll set up a more complex scenario using

Compositions

Browse to the Compositions section and

  1. Add a new composition.

  2. Enter a name such as djanga-comp.

  3. Paste the following composition into the code editor and save (don’t forget to replace $DOCKER_HUB_USERNAME):

db: # Create a `Postgres` database in a container named `db`
  image: postgres

web: # Create a container for the Django web application named `web`

  image: '$DOCKER_HUB_USERNAME/djanga:master' # Base the container on the image we pushed in the previous stage

  # Use `netcat` to wait for the db before starting the webapp
  command: bash -c "echo \"Waiting for DB\"; while ! nc -z db 5432; do sleep 0.1; done; python manage.py runserver 0.0.0.0:8000"

  ports:
    - '8000:8000'

  links:
    - db

Now that we’ve got a composition all set up, let’s return to the build settings and add an

Integration test

Under the Integration Test Script section paste the following script, then save and Build again:

echo "Starting test"

# Create a new container, link it to the web container (created in the composition) and test the webapp with a curl request.
# In the context of an integration test, all containers create in the composition are prefixed with `integration_` and suffixed by the container's index
docker run -it --link integration_web_1:web phusion/baseimage bash -c "curl --silent \"http://web:8000\" > /dev/null"

exit=$?

And there you have it!

djanga's People

Contributors

davidfeldi avatar noamt avatar noamt-codefresh avatar ncodefresh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.