testcontainers / testcontainers-jooq-codegen-maven-plugin

jOOQ code generator using Testcontainers
Apache License 2.0
49 stars 10 forks source link

How do I get this to run in my docker build stage? #30

Open oluwatimilehin opened 1 year ago

oluwatimilehin commented 1 year ago

I have a Dockerfile that does a multistage build where the build stage looks like:

#
# Build stage
#
FROM maven:3.9.1-eclipse-temurin-17 AS build
WORKDIR /app
COPY src ./src
COPY pom.xml .

RUN --mount=type=cache,target=/root/.m2 mvn clean package

This fails when it runs mvn clean package with the error:

#0 3.561 [INFO] Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
#0 3.876 [INFO] docker-machine executable was not found on PATH ([/opt/java/openjdk/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin])
#0 3.876 [ERROR] Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
#0 3.876        UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock)
#0 3.876        DockerDesktopClientProviderStrategy: failed with exception NullPointerException (Cannot invoke "java.nio.file.Path.toString()" because the return value of "org.testcontainers.dockerclient.DockerDesktopClientProviderStrategy.getSocketPath()" is null)As no valid configuration was found, execution cannot continue.

I understand that we need a valid docker daemon and there's none in the build stage, but I'm wondering if there's a workaround or maven flag I can specify to generate the sources without starting the container in the build stage. Any pointers on this, please?

romchellis commented 1 year ago

Hi @oluwatimilehin not sure that issue is related to this particullar project. but have you tried different base docker image which allows docker in docker?

oluwatimilehin commented 1 year ago

@romchellis Hey, thanks for getting back to me. I think it could be good if there was an option to generate the sources without running test containers, but maybe that's not realistic. What do you think?

I've read that docker in docker is not the best idea, but I'll look into that further.

eddumelendez commented 11 months ago

Have you checked the Testcontainers for java docs? See https://java.testcontainers.org/supported_docker_environment/continuous_integration/dind_patterns/#docker-only-example