[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: OpenShift Docker build strategy using Dockerfiles & MongoDB Database creation





On Tue, Nov 14, 2017 at 3:11 PM, Tien Hung Nguyen <tienhng nguyen gmail com> wrote:
Hello everybody,

I'm new to OpenShift Origin and I have a few questions:

My goal is to run an existing DevOps Dashboard Project on OpenShift Origin. The project does already workes on Docker (with Docker-compose.yaml and Dockerfile), consisting of the following 3 containers:
1. MongoDB
2. API
3. UI

In the Dockerfile of the API project I have the following commands:




ENV SPRING_DATA_MONGODB_DATABASE=dashboard
ENV SPRING_DATA_MONGODB_HOST=hygieia-mongodb
ENV SPRING_DATA_MONGODB_PORT=27017
ENV SPRING_DATA_MONGODB_USERNAME=dashboarduser
ENV SPRING_DATA_MONGODB_PASSWORD=dbpassword
ENV AUTH_EXPIRATION_TIME=7200000
ENV jasypt.encryptor.password=hygieiasecret
ENV AUTH_SECRET=hygieiasecret

RUN \
mkdir /hygieia

#COPY hygieia/ /hygieia
COPY *.jar /hygieia/
COPY properties-builder.sh /hygieia/

WORKDIR /hygieia

VOLUME ["/hygieia/logs"]

EXPOSE 8080
CMD ./properties-builder.sh &&\
java -Djava.security.egd=file:/dev/./urandom -jar api.jar --spring.config.location=/hygieia/dashboard.properties

The Docker-compose.yaml is as follows:
mongodb:
  image: mongo:latest
  environment:
    - MONGODB_USERNAME=dashboarduser
    - MONGODB_DATABASE=dashboarddb
    - MONGODB_PASSWORD=dbpassword
  volumes:
    - mongo:/data/db:rw
  ports:
    - "27017:27017"

hygieia-api:
  image: hygieia-api:latest
  volumes:
  - logs:/hygieia/logs
  environment:
    - jasypt.encryptor.password=hygieiasecret
    - SPRING_DATA_MONGODB_DATABASE=dashboarddb
    - SPRING_DATA_MONGODB_HOST=mongodb
    - SPRING_DATA_MONGODB_PORT=27017
    - SPRING_DATA_MONGODB_USERNAME=dashboarduser
    - SPRING_DATA_MONGODB_PASSWORD=dbpassword
    - AUTH_EXPIRATION_TIME=7200000
    - AUTH_SECRET=hygieiasecret
  links:
  - mongodb

hygieia-ui:
  image: hygieia-ui:latest
  container_name: hygieia-ui
  ports:
  - "8088:80"
  links:
  - hygieia-api

==> The sub projects (API, UI) have a sub directory called "docker". In this directory there is a Dockerfile, a .jar file, and relevant .properties and .sh files).

I have specified a Docker build strategy in the DeploymentConfig of the template file pointing to my Dockerfiles,

DeploymentConfig or BuildConfig?

 
however, it says that it can't find my files while building the images, which I have defined (*.jar, .sh file and properties file). My question is now, how can I bring those files into the build process that they work with my dockerfiles?

Have you been through our build documentation?
https://docs.openshift.org/latest/dev_guide/builds/index.html

in particular:
https://docs.openshift.org/latest/dev_guide/builds/build_inputs.html

and
https://docs.openshift.org/latest/dev_guide/builds/build_strategies.html#docker-strategy-options

are probably relevant to your goals.

 


Furthermore, could you tell me what is the best way to create a new Database inside MongoDB when initializing the pods/containers with the help of the .yaml template file? Which is the best section to do that?

A post-deployment hook in the database deploymentconfig, or a pre-deployment hook in your application deploymentconfig, is likely your best bet for initializing the DB. 

https://docs.openshift.org/latest/dev_guide/deployments/deployment_strategies.html#lifecycle-hooks

For example our rails quickstart does a db migration as part of the application's pre deployment hook:
https://github.com/openshift/origin/blob/master/examples/quickstarts/rails-postgresql.json#L146-L169

(this means the DB pod must be already up, and the app pod communicates remotely to the db pod to initialize it)

 



_______________________________________________
users mailing list
users lists openshift redhat com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users




--
Ben Parees | OpenShift


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]