JeremyAndress / fastapi-docker

Docker image with FastAPI with users management, ready for production :rocket:
MIT License
30 stars 8 forks source link

docker-compose -f local.yml build FAILS #3

Open LarryEitel opened 3 years ago

LarryEitel commented 3 years ago

Greetings. I successfully fired up your JeremyAndress/FastApi-simple repo. However, this one fails.

Running on Windows 10.

Thank you for any thoughts/suggestions.

`C:__repos\fastapi\fastapi-docker>docker-compose -f local.yml build WARNING: The POSTGRES_SERVER variable is not set. Defaulting to a blank string. Building nginx Step 1/2 : FROM nginx:1.19.1-alpine ---> ecd67fe340f9 Step 2/2 : ADD /nginx/site.conf /etc/nginx/conf.d/default.conf ---> Using cache ---> f7fcc5aec1c4

Successfully built f7fcc5aec1c4 Successfully tagged fastapi-docker_nginx:latest Building core Step 1/15 : FROM python:3.6.11-alpine3.11 ---> ad9bc7ab5910 Step 2/15 : ARG MYSQL_SERVER ---> Using cache ---> 36de4221a248 Step 3/15 : ARG POSTGRES_SERVER ---> Using cache ---> 5df22b7683aa Step 4/15 : ENV ENVTYPE=local ---> Using cache ---> 92fa15be7706 Step 5/15 : ENV PYTHONUNBUFFERED 1 ---> Using cache ---> 8228a1dc2c1a Step 6/15 : ENV APP_HOME=/home/app/web ---> Using cache ---> 2a9d3c040655 Step 7/15 : RUN mkdir -p $APP_HOME ---> Using cache ---> 535b4f2e510f Step 8/15 : WORKDIR $APP_HOME ---> Using cache ---> f4aa7c807743 Step 9/15 : ADD /compose/scripts.sh $APP_HOME ---> Using cache ---> 0c7aa2627ec4 Step 10/15 : ADD /requirements/$ENVTYPE.txt $APP_HOME ---> Using cache ---> 049bf14f50ed Step 11/15 : RUN chmod +x scripts.sh ---> Using cache ---> 5b684b5ca32e Step 12/15 : RUN ./scripts.sh ---> Running in 1c341fe2de08 fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz ERROR: unsatisfiable constraints: (missing): ] required by: world[tzdata fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz v3.11.7-19-gd6a090b561 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main] v3.11.7 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community] OK: 11277 distinct packages available fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz ERROR: unsatisfiable constraints: (missing): ] required by: world[ : not foundh: line 5: python3-dev ./scripts.sh: line 11: syntax error: unexpected "elif" (expecting "then") ERROR: Service 'core' failed to build : The command '/bin/sh -c ./scripts.sh' returned a non-zero code: 2

`

JeremyAndress commented 3 years ago

Thank you very much for using my app. My first suggestion is that you use development on a linux system. Because it is developed on ubuntu.

But apparently the problem you have is that your S.O. does not recognize bash syntax from scripts.sh file.

Hope these changes can fix the problem.

Current file status /compose/scripts.sh

# TIME ZONE
apk add --update tzdata
# PACKAGE
apk update && apk add --no-cache gcc make \
    python3-dev
# DATABASE PACKAGE
if [ $MYSQL_SERVER ]
then
    echo "MYSQL DEPENDENCIES..."
    apk add --no-cache mariadb-dev build-base libffi-dev
elif [ $POSTGRES_SERVER ]
then 
    echo "POSTGRE DEPENDENCIES..."
    apk add --no-cache postgresql-dev musl-dev
fi

Necessary changes:

#!/bin/sh

apk update && apk add --no-cache gcc make python3-dev tzdata

if [ $MYSQL_SERVER ]
then
    apk add --no-cache mariadb-dev build-base libffi-dev
elif [ $POSTGRES_SERVER ]
then 
    apk add --no-cache postgresql-dev musl-dev
fi
jerojasy commented 3 years ago

I'm also running on Windows 10 and the fix for me was to change line endings from CR LF (windows) to LF (Unix).

I did this with Notepad++ making this very easy and now I can build images. In "Edit" menu of Notepad++, you have "EOL conversion" that does exactly what you need.