GithubHelp home page GithubHelp logo

djangoanddocker's Introduction

Common Docker command

To build image

docker compose build

To fire up containers

docker compose up

djangoanddocker's People

Contributors

yiqing-lan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

djangoanddocker's Issues

Thanks for this repository

Hi @slow999

I learnt some things I never knew were doable in this little project of yours. The docker usage is topnotch. I have gone ahead to revise it for personal use.

My revision is shown below:

version: "3.7"

services:
  if_ndo_django:
    build: ./web/
    image: if_ndo_django
    restart: always
    container_name: cf_ndo_django
    command: >
      sh -c "python manage.py collectstatic --noinput 
      && uwsgi --ini core.uwsgi.ini"
    environment:
      DJANGO_SETTINGS_MODULE: core.settings
      SECRET_KEY: a989d11be926c6ca2f7035d3e42cb0d1b7e08b
      DEBUG: true
    volumes:
      - ndo-uwsgi-data:/tmp/uwsgi/
      - ./web:/code

  if_ndo_nginx:
    build: ./nginx/
    image: if_ndo_nginx
    restart: always
    container_name: cf_ndo_nginx
    volumes:
      - ndo-uwsgi-data:/tmp/uwsgi/
      - ./web/static:/var/www/core/assets
      - ./logs:/var/log/nginx/
    ports:
      - 8888:80
    depends_on: 
      - if_ndo_django

volumes:
  ndo-uwsgi-data:

Part of my revision includes updating the code to Django version 4, touching up the static repository and refactoring the Dockerfile.

web/Dockerfile

FROM python:3.10.7-alpine3.16

ENV PI="pip3 install --cache-dir . --disable-pip-version-check --find-links=."
WORKDIR /code
COPY requirements.txt /code

RUN apk add --no-cache build-base linux-headers && \
	pip3 download --cache-dir . --only-binary=:all pip setuptools wheel -r requirements.txt && \
    $PI pip setuptools wheel && $PI uwsgi -r requirements.txt && \
    apk del build-base linux-headers && rm -rf /var/cache/apk/*

nginx/Dockerfile

FROM nginx:latest

COPY nginx.conf /etc/nginx/nginx.conf
COPY core.nginx.conf /etc/nginx/sites-available/core.nginx.conf
RUN mkdir /etc/nginx/sites-enabled && ln -s /etc/nginx/sites-available/core.nginx.conf /etc/nginx/sites-enabled/

CMD ["nginx", "-g", "daemon off;"]

Also, I renamed the project from mysite to core. I was able to make these changes because you lead the way. Thanks

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.