Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Prepare static files inside the image file

Adam Bogdał98807dd05472
diff --git a/Dockerfile b/Dockerfile
index 1510f87343..898bd8a3b2 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,15 +7,24 @@ RUN \
apt-get clean && \
ln -s /usr/bin/nodejs /usr/bin/node
-ADD setup.py /app/setup.py
ADD requirements.txt /app/requirements.txt
RUN cd /app && pip install -r requirements.txt
-ADD package.json /node/package.json
-RUN cd /node && npm install
+ADD package.json /app/package.json
+RUN cd /app && npm install
+
+RUN useradd -ms /bin/bash saleor
ADD . /app
WORKDIR /app
+ENV PATH $PATH:/app/node_modules/.bin
+RUN echo "{\"allow_root\": true }" > ~/.bowerrc
+RUN bower install && grunt
+RUN python manage.py collectstatic --noinput
+
EXPOSE 8000
+ENV PORT 8000
+
ENTRYPOINT ["/app/compose/entrypoint.sh"]
+CMD uwsgi saleor/wsgi/uwsgi.ini
diff --git a/compose/entrypoint.sh b/compose/entrypoint.sh
index 9fdad117ef..bf3db2e990 100755
--- a/compose/entrypoint.sh
+++ b/compose/entrypoint.sh
@@ -2,17 +2,15 @@
set -e
USER=saleor
+APP_UID=`stat -c "%u" /app`
export DATABASE_URL=postgres://$DB_ENV_DB_USER:$DB_ENV_DB_PASS@db/$DB_ENV_DB_NAME
-if [ $(cat /etc/passwd | grep $USER | wc -l) == "0" ]; then
- useradd -u `stat -c "%u" /app` -m $USER
+if [ $APP_UID != "0" ]; then
+ if [ $APP_UID != $(id -u $USER) ]; then
+ usermod -u $APP_UID $USER
+ fi
+ su $USER -c "PATH=$PATH:/app/node_modules/.bin $*"
fi
-chown $USER.$USER /node -R
-if [[ ( $1 == "/app/compose/start.sh" ) && ( ! -d "/app/node_modules" ) ]]; then
- echo Copying /node/node_modules to /app/node_modules..
- su saleor -c "cp -r /node/node_modules /app"
-fi
-
-su saleor -c "PATH=$PATH:/app/node_modules/.bin $*"
+exec "$@"
diff --git a/compose/start.sh b/compose/start.sh
deleted file mode 100755
index 7bdeb7c07e..0000000000
--- a/compose/start.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-bower install
-grunt
-saleor collectstatic --noinput
-
-gunicorn saleor.wsgi.static -b 0.0.0.0:8000 --log-file -
diff --git a/docker-compose.yml b/docker-compose.yml
index c5ec9a8aae..6a244fc0e3 100755
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,4 +12,3 @@ web:
- '8000:8000'
volumes:
- .:/app
- command: /app/compose/start.sh