anyproto / any-sync-dockercompose

docker-compose for testing any-sync
MIT License
238 stars 30 forks source link

guide improve: Run on Windows may have issue which bacause auto convert LF to CRLF by Git. #30

Closed Fradeet closed 3 months ago

Fradeet commented 3 months ago

Have you read a contributing guide?

Clear and concise description of the problem

When I follow guide run this:

# Generate config
docker build -t generateconfig -f Dockerfile-generateconfig .
docker run --rm -v ${PWD}/etc:/opt/processing/etc --name any-sync-generator generateconfig
# Run containers
docker compose up -d

It throw error, like:

(base) PS D:\Any-Sync\any-sync-dockercompose> docker build -t generateconfig -f .\Dockerfile-generateconfig .
...
 => ERROR [generator 8/8] RUN ./generate_config.sh                                                                 0.4s
------
 > [generator 8/8] RUN ./generate_config.sh:
#0 0.413 /bin/sh: ./generate_config.sh: not found
------
Dockerfile-generateconfig:8
--------------------
   6 |     COPY --chmod=777 docker-generateconfig/generate_config.sh .env ./
   7 |     RUN source .env
   8 | >>> RUN ./generate_config.sh
   9 |
  10 |     FROM alpine:3.18.4
--------------------
ERROR: failed to solve: process "/bin/sh -c ./generate_config.sh" did not complete successfully: exit code: 127

Then I try setup manually, then throw many error:

539290ca3503:/opt/generateconfig# source .env
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
(base) PS D:\Any-Sync\any-sync-dockercompose> docker run --rm -v ${PWD}/docker-generateconfig/etc:/opt/processing/etc --name any-sync-generator generateconfig
/bin/sh: ./processing.sh: not found
c1994526c941:/opt/processing# ./setListenIp.py "127.0.0.1" "./generateconfig/nodes.yml"
': No such file or directory

Suggested solution

I search web, and I founded the Git would automatically converts to CRLF. This is the reason for all the issues. image

To solve this issue, just disable Git auto convert to CRLF:

git config --global core.autocrlf false

The guide may need some improvement.

Alternative

No response

Additional context

No response