Git Product home page Git Product logo

testing_docker_ci's Introduction

testing_docker_ci

This is to test a docker django container with ci

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development purposes.

Prerequisites

Docker and Docker Compose

Installing

The order of operation should be followed.

Fork the repo and then clone it down to your local machine from your account

git clone https://github.com/phansiri/testing_docker_ci.git

Go to the root directory

cd testing_docker_ci

Build the docker-compose file and detach so it runs in the background

docker-compose up --build -d

Check the container ids for future use

docker ps

Configure the postgres database name, user, and password - the default login to psql is postgres without a password

docker container exec -it [container_id] psql -U postgres

Create database, create user, and grant database to user

CREATE DATABASE databasename;
CREATE USER dbuser WITH PASSWORD 'password';
GRANT ALL ON DATABASE databasename TO dbuser;
\q

Now update these specific locations on settings.py of your project

SECRET_KEY = os.environ.get('SECRET_KEY', 'not-so-secret-key')

DEBUG = int(os.environ.get('DEBUG', default=1))

DATABASES = {
    'default': {
        'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'),
        'NAME': os.environ.get('DB_DATABASE_NAME', os.path.join(BASE_DIR, 'db.sqlite3')),
        'USER': os.environ.get('DB_USERNAME', 'user'),
        'PASSWORD': os.environ.get('DB_PASSWORD', 'password'),
        'HOST': os.environ.get('DB_HOST', 'localhost'),
        'PORT': os.environ.get('DB_PORT', '5432'),
    }
}

Create .env and .env-db and populate the files ** ensure to the files are ignored.

.env

DEBUG=1
SECRET_KEY=

DB_ENGINE=django.db.backends.postgresql
DB_TYPE=postgres
DB_DATABASE_NAME=databasename  
DB_USERNAME=dbuser
DB_PASSWORD=password  
DB_HOST=db
DB_PORT=5432

.env-db

POSTGRES_DB=databasename
POSTGRES_USER=docdbuserking_user
POSTGRES_PASSWORD=password

Rebuild the container again with

docker-compose up --build -d

Run migrate and create a super user

docker ps
docker container exec -it [container_id] python manage.py migrate
docker container exec -it [container_id] python manage.py createsuperuser

Check what the docker-machine ip address is

docker-machine ls

This will tell you the ip address to put into the browser. The port number will be what is in the docker-compose file. For example

http://192.168.99.100:8001/

To shut it down and kill the volume

docker-compose down -v

To shut it down but NOT kill the volume

docker-compose down

Good luck!

Next

Connect it to Gitlab! - coming soon...

testing_docker_ci's People

Contributors

phansiri avatar dependabot[bot] 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.