GithubHelp home page GithubHelp logo

Comments (3)

mhall119 avatar mhall119 commented on June 10, 2024

For Docker we're going to use environment variables passed through to the container to configure things like this, would what work for Vagrant too?

from gettogether.

JonTheNiceGuy avatar JonTheNiceGuy commented on June 10, 2024

Yes, we can. There are two options

  1. we can use the env line like below
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  # config.vm.box_check_update = false
  config.vm.network "forwarded_port", guest: 8000, host: 8080
  # config.vm.network "public_network"
  # config.vm.synced_folder "../data", "/vagrant_data"
  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get upgrade -y
    apt-get install -y python3 python3-pip
  SHELL
  config.vm.provision "shell",
    env: {"DEBUG" => "#{ENV['DEBUG']}"},
    run: "always",
    inline: <<-SHELL
      cd /vagrant
      pip3 install -r requirements.txt
      python3 manage.py migrate
      python3 manage.py runserver 0.0.0.0:8000
    SHELL
end
  1. We could create an env file to load:
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  # config.vm.box_check_update = false
  config.vm.network "forwarded_port", guest: 8000, host: 8080
  # config.vm.network "public_network"
  # config.vm.synced_folder "../data", "/vagrant_data"
  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get upgrade -y
    apt-get install -y python3 python3-pip
  SHELL
  config.vm.provision "shell",
    run: "always",
    inline: <<-SHELL
      cd /vagrant
      source envfile
      pip3 install -r requirements.txt
      python3 manage.py migrate
      python3 manage.py runserver 0.0.0.0:8000
    SHELL
end

While both of these examples would work, they're not perfect (I knocked them up in a couple of minutes) :)

from gettogether.

mhall119 avatar mhall119 commented on June 10, 2024

I've added an environ_settings.py that will let you set certain config values from your environment variables. You can use it either by adding --settings=get_together.environ_settings to the end of your manage.py command, or by setting DJANGO_SETTINGS_MODULE=get_together.environ_settings in your environment.

And example command would be:
DJANGO_SETTINGS_MODULE='get_together.environ_settings' DATABASE_URL='sqlite:////path/to/your/db.sqlite3' SECRET_KEY='foobar' python3 manage.py runserver 0.0.0.0:8000

DATABASE_URL follows this project's spec and requires pip installing dj-database-url (which is now in the requirements.txt).

I hope this does what you need it to do. If not, let me know what's missing.

from gettogether.

Related Issues (20)

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.