Can I create parser classes on container initialization? - docker

I'm using docker and docker-compose to easily setup parser-server for a project using the parseplatform/parse-server image.
So far everything runs perfectly and I can go and manually add the classes I need for the app via the parse-dashboard, but I would like to automate this.
Is there any way to pass a schema on parse first run to populate the database with the required classes? I'm keeping PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION as false.
Any ENV variables that I'm not aware of? Is the only alternative pulling the repo and building the image with some custom config?
As far my search went I can't find any info on the subject. Parse seems to be a very powerful tool, but the docs tend to be very simplistic as far I've seen.
Thanks for any input/help.
docker-compose.yml
version: '3'
services:
mongodb:
image: mongo
container_name: parse-mongo
volumes:
- ./mongodb:/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME
- MONGO_INITDB_ROOT_PASSWORD
parse:
image: parseplatform/parse-server
container_name: parse-server
ports:
- 1337:1337
links:
- mongodb:mongo
depends_on:
- mongodb
environment:
- PARSE_SERVER_APPLICATION_ID
- PARSE_SERVER_APP_NAME
- PARSE_SERVER_MASTER_KEY
- PARSE_SERVER_DATABASE_URI
- PARSE_SERVER_MOUNT_GRAPHQL
- PARSE_SERVER_MOUNT_PLAYGROUND
- PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION
.env
# MONGO DB
MONGO_INITDB_ROOT_USERNAME=###
MONGO_INITDB_ROOT_PASSWORD=###
# PARSE SERVER
PARSE_SERVER_APPLICATION_ID=###
PARSE_SERVER_APP_NAME=###
PARSE_SERVER_MASTER_KEY=###
PARSE_SERVER_DATABASE_URI="mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}#mongo:27017"
PARSE_SERVER_MOUNT_GRAPHQL=1
PARSE_SERVER_MOUNT_PLAYGROUND=1
PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION=0

Related

Multiple database in docker compose

i am trying to create 2 database in a docker compose yml file, one is for the app and the other is for the test part, in the java spring framework i do use the the url like "jdbc:postgresql://localhost:5401/webTest", but id does not work.
From the cmd, i can connect to the database-user with no problem and the table are there but i can not connect to the database-test, is there a specific issue i am blind about?
#service
services:
database-user:
#container_name: postgres-user
image: postgres
ports:
- 5401:5432
volumes:
- postgres-user:/var/lib/postgresql/data
- ./scripts/create-table-db.sql:/docker-entrypoint-initdb.d/create-table-db.sql
environment:
- POSTGRES_USER=webAppUser
- POSTGRES_PASSWORD=user
- POSTGRES_DB=webApp
database-test:
#container_name: postgres-test
image: postgres
ports:
- 5402:5432
volumes:
- postgres-test:/var/lib/postgresql/data
- ./scripts/create-table-db.sql:/docker-entrypoint-initdb.d/create-table-db.sql
environment:
- POSTGRES_USER=webAppTest
- POSTGRES_PASSWORD=test
- POSTGRES_DB=webTest
volumes:
postgres-user:
postgres-test:
i did try to follow some example like here but its not clear.
(the database-user does work also in the java part)

Parse-Server Docker-Container custom volume saved data not working

I am new to parse-server and to docker world, and I think that either I did not understand this properly or it is not working. Sorry if this will come as a stupid question.
So from docker documentation, I understand that if I want to bind a folder location to my docker location I have to do something like this.
volumes:
- /host/path/to/folder:/docker/path/to/folder
But the thing that I am missing is that after I create all my docker and I bind the volume paths like this when I am adding new rows into my MongoDB database I will have nothing saved into those folders. Can anyone explain to me what I am doing wrong?
Basically, I am trying to save all my changes from MongoDB and the server into a local folder.
My docker-compose:
version: '3.9'
services:
database:
image: mongo:6.0.1
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
volumes:
- ./data/mongodb:/data/mongodb
server:
restart: always
image: parseplatform/parse-server:5.2.5
ports:
- 1337:1337
environment:
- PARSE_SERVER_APPLICATION_ID=COOK_APP
- PARSE_SERVER_MASTER_KEY=MASTER_KEY_1
- PARSE_SERVER_DATABASE_URI=mongodb://admin:admin#mongo/parse_server?authSource=admin
- PARSE_ENABLE_CLOUD_CODE=yes
- PARSE_SERVER_URL=http://10.0.2.2:1337/parse
links:
- database:mongo
volumes:
- ./data/server:/data/server
dashboard:
image: parseplatform/parse-dashboard:4.1.4
ports:
- "4040:4040"
depends_on:
- server
environment:
- PARSE_DASHBOARD_APP_ID=COOK_APP
- PARSE_DASHBOARD_APP_NAME=COOK_APP
- PARSE_DASHBOARD_MASTER_KEY=MASTER_KEY_1
- PARSE_DASHBOARD_USER_ID=admin
- PARSE_DASHBOARD_USER_PASSWORD=admin
- PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=true
- PARSE_DASHBOARD_SERVER_URL=http://localhost:1337/parse
volumes:
- ./data/dashboard:/data/dashboard
UPDATE:
After I've checked your response regarding ./data/mongodb:/data/db is working just partially. In a sense that I have these 2 cases.
If I will use it like this data/mongodb:/data/db without that . in order to save that data into my root directory, then everything is working fine. But I would like to save it in my local directory where all the projects will be.
So if I am doing as you said ./data/mongodb:/data/db in order to save it into the local directory my MongoDB is not going to star and I will get this error message for some unknown reason.
{"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"W", "c":"STORAGE", "id":22347, "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."} 2022-09-07T16:05:52.524152876Z {"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"F", "c":"STORAGE", "id":28595, "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"1: Operation not permitted"}} 2022-09-07T16:05:52.524168870Z {"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"F", "c":"ASSERT", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":702}} 2022-09-07T16:05:52.524183328Z {"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"F", "c":"ASSERT", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
Any idea why?
If you check the "where to store data" section of the mongo image documentation (https://hub.docker.com/_/mongo), you will see that, inside the container, mongo actually saves the data in the folder /data/db (and not /data/mongodb). So you will have to bind it:
volumes:
- ./data/mongodb:/data/db

RabbitMQ with docker-compose is not restoring data

I want to use rabbitMQ, for this I'm using this docker-compose.yml file:
version: '2'
services:
rabbitmq:
image: rabbitmq:management
ports:
- "5672:5672"
- "15672:15672"
volumes:
- /tmp_data:/var/lib/rabbitmq
it works as expected.
I'm entering some users over the admin GUI interface.
But when i delete the container, I was expecting to still have the created users.
But it seems, that rabbitMQ is not saving it in the folder I specified.
I was going through the documentation, but i haven't found any other folder where this configurations are saved
Thanks for you help.
I think you need these three volumes which include all configs, and you need to add one more ENV:
environment:
- RABBITMQ_NODENAME: MYNODE#rabbitmq
volumes:
- ./rabbitmq:/var/lib/rabbitmq
- ./definitions.json:/opt/definitions.json
- ./rabbitmq.config:/etc/rabbitmq/rabbitmq.config
see this

Publish multiple images on hub.docker.com in a single repository

I am new to Docker so and this is giving me a headache. I finish developing a site in Magento linking multiple images using docker-compose.yml.
Here is my docker-compose.yml
version: '3'
services:
web:
image: webdevops/php-apache-dev:7.1
container_name: web
restart: always
user: application
environment:
- WEB_ALIAS_DOMAIN=local.domain.com
- WEB_DOCUMENT_ROOT=/app/pub
- PHP_DATE_TIMEZONE=EST
- PHP_DISPLAY_ERRORS=1
- PHP_MEMORY_LIMIT=2048M
- PHP_MAX_EXECUTION_TIME=300
- PHP_POST_MAX_SIZE=500M
- PHP_UPLOAD_MAX_FILESIZE=1024M
volumes:
- "./:/app:cached"
ports:
- "80:80"
- "443:443"
- "32823:22"
links:
- mysql
mysql:
image: mariadb:10
container_name: mysql
restart: always
ports:
- "52000:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=magento
volumes:
- db-data:/var/lib/mysql
phpmyadmin:
container_name: phpmyadmin
restart: always
image: phpmyadmin/phpmyadmin:latest
environment:
- MYSQL_ROOT_PASSWORD=root
- PMA_USER=root
- PMA_PASSWORD=root
ports:
- "8080:80"
links:
- mysql:db
depends_on:
- mysql
volumes:
db-data:
external: false
Then docker-compose up -d --build. I have 3 images and 3 containers running on my local machine.
I want to publish these image on hub.docker.com so anyone can download the image and get all the containers running.
Also is there a way to add a MySQL DB to the image, so anyone can have the same running website like I had on my local?
Remember that the only thing you can publish on Docker Hub is Docker images; you can't publish containers, volumes, Docker Compose YAML files, or other artifacts. Since the YAML file is a fairly straightforward text file it's very common to publish that on GitHub, along with a README file explaining how to use it.
You don't need to push the phpmyadmin/phpmyadmin or mariadb images because those are standard Docker Hub images, so you only need to push your custom image. I would highly recommend removing the volumes: that mounts your local development tree over the image contents to validate that the image actually has what you expect.
Is there a way to add mysql DB to the image
No. The various standard Docker database images are built in a way that it is extremely difficult to build an image containing prepopulated data. Wordpress image with mysql data has some good discussion on the topic, and MySQL Docker container is not saving data to new image has some good analysis in the question proper.

Join docker images in a single container [duplicate]

This question already has an answer here:
Build a single image based on docker compose containers
(1 answer)
Closed 9 months ago.
I have an application composed of a front end, a back end and a mongodb database, each of these dockerized in a container. When I build them with docker compose I have as many images as parts in my application (3).
Is there any way to build a single container from these 3 images and therefore a single image?
Thanks
You can write a Dockerfile if you want to run your application as a single container. it will give you single image as well.
I guess you could do this if you really wanted to. The preferred way is to use docker-compose for this. I would suggest that you create a docker-compose.yml file that helps you setup this:
nginx->frontend (possibly with server side rendering) -> backend -> mongodb
The idea behind docker-compose is to easily get that multi container application up and running using a docker-compose.yml file , then you can just bring up the application with:
$ docker-compose up
You could it setup with something like this:
(This is a hypothetical docker-compose.yml file, but with your correct values it should work. Let me know if you have any questions:
version: '2'
services:
frontend-container:
image: frontend:latest
links:
- backend-container
environment:
- DEBUG=True
restart: always
environment:
- BASE_HOST=http://backend-container:8000/
backend-container:
image: nodejs-backend:latest
links:
- mongodb
environment:
- NODE_ENV=production
- BASE_HOST=http://django-container:8000/
restart: always
mongodb:
image: mongo:latest
container_name: "mongodb"
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- ./data/db:/data/db
command: mongod --smallfiles --logpath=/dev/null
nginx-container:
image: nginx-container-custom-config:latest
links:
- frontend-container
ports:
- "80:80"

Resources