So I'm making a dockerfile and I want it to set up a project and import a database after that. I'm using XAMPP and the included MariaDB. I know I need to use CMD for the import since XAMPP must be running. I'm trying to import the DB by running a sql script that does the job in the DB prompt.
I tried using && and ; for chaining commands in a single line but it won't work since it tries to run all commands on the terminal prompt before waiting on MariaDB prompt. Any Ideas?
This is my docker file and last line is my attempt to import the database:
FROM cswl/xampp
COPY . /opt/lampp/htdocs/
WORKDIR /opt/lampp/htdocs/
RUN curl -sS https://getcomposer.org/installer | /opt/lampp/bin/php &&\
/opt/lampp/bin/php composer.phar install
RUN curl https://s3.amazonaws.com/careers-picpay/lista_relevancia_1.txt --output db/lista_relevancia_1.txt &&\
curl http://s3.amazonaws.com/careers-picpay/lista_relevancia_2.txt --output db/lista_relevancia_2.txt &&\
curl https://s3.amazonaws.com/careers-picpay/users.csv.gz --output db/users.csv.gz
RUN gzip -d db/users.csv.gz
CMD /opt/lampp/bin/mysql -u root && source ./initdb.sql
UPDATE: So I also tried to replace my two commands with one with the MariaDB -e option, for executing a line after login... Didn't work, database wasn't created and I don't know why. This is the command:
CMD /opt/lampp/bin/mysql -u root -e "source ./initdb.sql"
CMDis starting themysqlprocess and getting no further.