skip to Main Content

I have below dockerfile

FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base

RUN apt-get update
RUN apt-get install -y libmotif-dev build-essential

COPY . /usr/src/myapp

COPY oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/redist /usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/demo

WORKDIR /usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix/
RUN make

WORKDIR /app

RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

COPY . .

For reference, locally I have following files in directory oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix/

below is makefile

all:     casample taredir textdemo extract_archive extract_object memoryio parsepst batch_process_ca

.PHONY: all

taredir:
    @TARGET="taredir" 
    MAYBE_XPRINTER="" 
    TARGETDEPS="-lsc_da -lsc_ta -lsc_lo " 
    ./configure

textdemo:
    @TARGET="textdemo" 
    MAYBE_XPRINTER="" 
    TARGETDEPS="-lsc_da -lsc_ta -lsc_lo -lXm -lXt -lX11" 
    ./configure

casample:
    @TARGET="casample" 
    TARGETDEPS="-lsc_da -lsc_ca -DUNIX" 
    ./configure
    
extract_archive:
    @TARGET="extract_archive" 
    TARGETDEPS="-lsc_da" 
    ./configure
            
extract_object:
    @TARGET="extract_object" 
    TARGETDEPS="-lsc_da -lsc_ca" 
    ./configure    
    
memoryio:
    @TARGET="memoryio" 
    TARGETDEPS="-lsc_da -lsc_ca" 
    ./configure  

parsepst:
    @TARGET="parsepst" 
    TARGETDEPS="-lsc_da -lsc_ca" 
    ./configure      

batch_process_ca:
    @TARGET="batch_process_ca" 
    TARGETDEPS="-lsc_ca -lsc_da -DUNIX" 
    ./configure    

and one configure file (content of that may not be relevant for this question) on same path.

When I run docker build -t myapp-oracle-extract .

I get below error.

 => [base  7/11] WORKDIR /usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix/                                        1.0s 
 => ERROR [base  8/11] RUN make                                                                                                                             1.9s 
------
 > [base  8/11] RUN make:
1.149 /bin/sh: 1: ./configure: not found
1.149 make: *** [makefile:32: casample] Error 127
------
Dockerfile:46
--------------------
  44 |     WORKDIR /usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix/
  45 |     # This command compiles your app using GCC, adjust for your source code
  46 | >>> RUN make
  47 |
  48 |     WORKDIR /app
--------------------
ERROR: failed to solve: process "/bin/sh -c make" did not complete successfully: exit code: 2

To print PWD, I added below to makefile to see if file is present.

print_pwd:
    @echo "Current directory: $(shell pwd)"
    @echo "Files:"
    @ls -la

.PHONY: print_pwd

and it gave following answer.

Current directory: /usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix
Files:
total 24
drwxr-xr-x  2 root root 4096 Jan 10 16:24 .
drwxr-xr-x 11 root root 4096 Nov 27 09:51 ..
-rwxr-xr-x  1 root root 3064 Nov 27 09:51 README
-rwxr-xr-x  1 root root 7544 Nov 27 09:51 configure
-rwxr-xr-x  1 root root 1710 Jan 10 16:58 makefile

In dockerfile, to check files, I added below.

RUN ls -l && pwd

It gave me following output.

Step 7/13 : RUN ls -l && pwd
 ---> Running in f180d47b647a
total 16
-rwxr-xr-x 1 root root 3064 Nov 27 09:51 README
-rwxr-xr-x 1 root root 7544 Nov 27 09:51 configure
-rwxr-xr-x 1 root root 1710 Jan 10 16:58 makefile
/usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix

Why it is unable to find ./configure even thought it has been copied. Does it run from different context? Why makefile is found but not configure file

2

Answers


  1. Chosen as BEST ANSWER

    After rigorous reasoning with AI, AI suggested below (Turned out that content of file which didn't seem important in question was the primary issue).

    RUN dos2unix ./configure
    

    Reason mentioned:

    The error occurred because the ./configure script had CRLF line endings, which caused issues when the script was run in a Unix-based environment. The dos2unix utility removes the extra carriage return (CR) characters, allowing the script to be interpreted correctly by the Unix shell.
    

  2. File Permissions Issue:

    1: In the Docker build context, the files you copy into the container retain their permissions unless explicitly changed.

    2: If the configure file does not have execute (+x) permissions locally, it will not be executable in the container.

    Updated Dockerfile:

    FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base

    RUN apt-get update
    RUN apt-get install -y libmotif-dev build-essential

    COPY . /usr/src/myapp

    WORKDIR /usr/src/myapp/oracle-outside-in-content-access-8.5.7.0.0-linux-x86-64/sdk/samplecode/unix/

    RUN chmod +x ./configure

    RUN ls -l

    RUN make

    WORKDIR /app

    RUN adduser -u 5678 –disabled-password –gecos "" appuser && chown -R

    appuser /app

    USER appuser

    COPY . .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search