I have the below working docker file:
# Use the Oracle SQLcl image as the base image
FROM container-registry.oracle.com/database/sqlcl:latest
# Set the current working directory
WORKDIR /app/
# Set the TNS_ADMIN environment variable
ENV TNS_ADMIN /opt/oracle/network/admin/
# Copy the TNSNAMES.ORA file into the container
COPY TNSNAMES.ORA $TNS_ADMIN/TNSNAMES.ORA
COPY scripts/ scripts/
# Login with AQTOPDATA
ENTRYPOINT ["sql", "mycredentials", "@scripts/script1.sql"]
However, I would like to parametrize @scripts/script1.sql to take scripts from a public repository, instead of being harcoded like that. For example, let's say there are the below files in an open repository:
script1.sql
script2.sql
I would like to be able to do something like (pseudo code) when I run the container:
docker run mycontainer --parameter https://github.com/repo/script2.sql
How can I achieve this?
Just remove @script/script1.sql
from your ENTRYPOINT
, and put it in CMD
, so that you have:
ENTRYPOINT ["sql", "mycredentials"]
CMD ["@scripts/script1.sql"]
If you just docker run myimage
, it will run:
sql mycredentials @scripts/script1.sql
But if you run instead docker run myimage https://github.com/repo/script2.sql
, then it will run:
sql mycredentials https://github.com/repo/script2.sql