#559 Improve Containerization
Merged 4 years ago by lholecek. Opened 4 years ago by lholecek.
lholecek/greenwave improve-containerization  into  master

file modified
+10 -5
@@ -28,13 +28,18 @@ 

          && curl -O --insecure $cacert_url \

          && update-ca-trust extract; \

      fi

+ 

  # This will allow a non-root user to install a custom root CA at run-time

  RUN chmod 777 /etc/pki/tls/certs/ca-bundle.crt

- COPY . .

- ENV GREENWAVE_SUBJECT_TYPES_DIR /src/conf/subject_types

- RUN pip3 install . --no-deps

- # Remove the default fedmsg config files included in the repo

- RUN rm -rf ./fedmsg.d

+ 

+ COPY . /tmp/code

+ RUN cd /tmp/code \

+     && pip3 install . --no-deps \

+     && mkdir /src/docker \

+     && cp -v docker/docker-entrypoint.sh /src/docker \

+     && cp -vr conf /src \

+     && rm -rf /tmp/*

+ 

  USER 1001

  EXPOSE 8080

  ENTRYPOINT ["/src/docker/docker-entrypoint.sh"]

file modified
+2 -2
@@ -3,11 +3,11 @@ 

    dev:

      build: .

      user: ${DEV_USER_ID:-1000}

-     working_dir: /code

+     working_dir: /src

      env_file: ["docker/dev.env"]

      command: ["bash", "-c", "./docker/dev-command.sh"]

      volumes:

-       - ./:/code:ro,z

+       - ./:/src:ro,z

        - ./docker/home:/home/dev:rw,z

        - ./docker/greenwave-settings.py:/etc/greenwave/settings.py:ro,z

        - ./conf/policies/:/etc/greenwave/policies/:ro,z

@@ -15,4 +15,31 @@ 

  }

  

  main

+ 

+ if [ -z "$GREENWAVE_CONFIG"]; then

+     if [ -f /etc/greenwave/settings.py ]; then

+         export GREENWAVE_CONFIG=/etc/greenwave/settings.py

+     elif [ -f /src/conf/settings.py ]; then

+         export GREENWAVE_CONFIG=/src/conf/settings.py

+     else

+         export GREENWAVE_CONFIG=/src/conf/settings.py.example

+     fi

+ fi

+ 

+ if [ -z "$GREENWAVE_SUBJECT_TYPES_DIR"]; then

+     if [ -d /etc/greenwave/subject_types ]; then

+         export GREENWAVE_SUBJECT_TYPES_DIR=/etc/greenwave/subject_types

+     else

+         export GREENWAVE_SUBJECT_TYPES_DIR=/src/conf/subject_types

+     fi

+ fi

+ 

+ if [ -z "$GREENWAVE_POLICIES_DIR"]; then

+     if [ -d /etc/greenwave/policies ]; then

+         export GREENWAVE_POLICIES_DIR=/etc/greenwave/policies

+     else

+         export GREENWAVE_POLICIES_DIR=/src/conf/policies

+     fi

+ fi

+ 

  exec "$@"

file modified
+1 -1
@@ -43,7 +43,7 @@ 

      REQUESTS_VERIFY = True

  

      POLICIES_DIR = '/etc/greenwave/policies'

-     SUBJECT_TYPES_DIR = _local_conf_dir('subject_types')

+     SUBJECT_TYPES_DIR = '/etc/greenwave/subject_types'

  

      MESSAGING = 'fedmsg'

  

@@ -3,6 +3,11 @@ 

  from greenwave.app_factory import create_app

  

  

+ @pytest.fixture(autouse=True)

+ def mock_env_config(monkeypatch):

+     monkeypatch.delenv('GREENWAVE_CONFIG')

+ 

+ 

  @pytest.fixture

  def app():

      app = create_app(config_obj='greenwave.config.TestingConfig')

file modified
+3
@@ -101,6 +101,9 @@ 

      if os.environ.get('GREENWAVE_SUBJECT_TYPES_DIR'):

          config['SUBJECT_TYPES_DIR'] = os.environ['GREENWAVE_SUBJECT_TYPES_DIR']

  

+     if os.environ.get('GREENWAVE_POLICIES_DIR'):

+         config['POLICIES_DIR'] = os.environ['GREENWAVE_POLICIES_DIR']

+ 

      return config

  

  

Use a default configuration in container

Remove unneeded source files from container

This makes the container work out of the box for development. You can mount custom configuration at /src/conf/.

This also normalizes the default paths in configuration (/etc/greenwave/ base dir).

rebased onto f2ea7be86f708ccce1ee235d31ee8022dbdb5300

4 years ago

rebased onto 14216a0e73c6d6579c5a79e5bdf04c89d708650e

4 years ago

rebased onto 9420360

4 years ago

3 new commits added

  • Tests: Avoid using GREENWAVE_CONFIG variable in tests
  • Use a default configuration in container
  • Remove unneeded source files from container
4 years ago

I'm not a docker-compose expert. But for what I know it looks good \o/

Pull-Request has been merged by lholecek

4 years ago