I have an API that needs gbak to work cause of this call:
String command = "gbak -b -v -g -user " + username + " -password " + password + " " + databasePath + " " + backupPathUpdated;
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();
process.waitFor();
I created a dockerfile like this:
# Use an official OpenJDK runtime as a parent image
FROM openjdk:17-alpine
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Make port 8080 available to the world outside this container
EXPOSE 8080
# Run application when the container launches
CMD ["java", "-jar", "target/poc-docker-0.0.1-SNAPSHOT.jar"]
When I tried to run the image, I faced this error:
Java.io.IOException: Cannot run program "gbak": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1142)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at xxxxxxxxxxxxxxxxxxxxxxxxxxxx.BackupSchedulerService.getBackup(BackupSchedulerService.java:52)
at xxxxxxxxxxxxxxxxxxxxxxxxxxxx.BackupSchedulerService.lambda$executeBackup$0(BackupSchedulerService.java:35)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:313)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1109)
... 4 more
I tried to change my dockerfile to this:
# Use an official OpenJDK runtime as a parent image
FROM openjdk:17-alpine
# Set the working directory to /app
WORKDIR /app
# Install gbak
RUN apk --no-cache add firebird
# Copy the current directory contents into the container at /app
COPY . /app
# Make port 8080 available to the world outside this container
EXPOSE 8080
# Run application when the container launches
CMD ["java", "-jar", "target/poc-docker-0.0.1-SNAPSHOT.jar"]
but then I can't create a image, this is the error:
=> ERROR [3/4] RUN apk --no-cache add firebird 1.3s
8 | >>> RUN apk --no-cache add firebird
9 |
10 | # Copy the current directory contents into the container at /app
--------------------
How can I solve my problem?
I tried to change dockerfile, to have gbak dependency, but I had another error.
UPDATE:
I could solve using this in my dockerfile:
RUN apk --no-cache add wget tar procps xz make build-base
&& wget https://github.com/FirebirdSQL/firebird/releases/download/v4.0.4/Firebird-4.0.4.3010-0.i686.tar.gz
&& tar -xzf Firebird-4.0.4.3010-0.i686.tar.gz
&& cd Firebird-4.0.4.3010-0.i686
&& ls -l
&& wget https://github.com/libtom/libtommath/releases/download/v1.2.0/ltm-1.2.0.tar.xz
&& tar -xJf ltm-1.2.0.tar.xz
&& cd libtommath-1.2.0
&& make
&& make install
&& cd ../
&& apk del wget tar xz make build-base
&& rm -rf /var/cache/apk/* /app
It seems that the package firebird is not available in the Alpine package repositories. I would suggest trying to manually download and install the Firebird database server tools in your dockerfile, something similar to this:
# firebird download and install
RUN wget https://github.com/FirebirdSQL/firebird/releases/download/R3_0_9/Firebird-3.0.9.53074-0.amd64.tar.gz \
&& tar -xzf Firebird-3.0.9.53074-0.amd64.tar.gz \
&& cd Firebird-3.0.9.53074-0.amd64 \
&& ./install.sh -silent
Consider that I fabricated the GitHub link, you will need to change it based on your requirements. Let me know if manually installing it solves your issues.