From 6dbc50bdf2218afd90ed9ddd4cf65871d2b6e23f Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Tue, 1 Feb 2022 16:41:14 +0100 Subject: [PATCH 1/8] Add the python package directory to PATH --- .gitpod.Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 5be3525..3ea5640 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -1,9 +1,9 @@ FROM couchbase:latest RUN echo "* soft nproc 20000\n"\ -"* hard nproc 20000\n"\ -"* soft nofile 200000\n"\ -"* hard nofile 200000\n" >> /etc/security/limits.conf + "* hard nproc 20000\n"\ + "* soft nofile 200000\n"\ + "* hard nofile 200000\n" >> /etc/security/limits.conf RUN apt-get update && export DEBIAN_FRONTEND=noninteractive &&\ apt-get install -y wget &&\ @@ -13,14 +13,14 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive &&\ apt-get install -y libssl-dev &&\ apt-get install -y socat sudo &&\ apt-get update &&\ - export PATH="$PATH:/usr/local/bin" &&\ + export PATH="$PATH:/usr/local/bin:/home/gitpod/.local/bin" &&\ export FLASK_APP=src/app &&\ export FLASK_ENV=development RUN addgroup --gid 33333 gitpod && \ - useradd --no-log-init --create-home --home-dir /home/gitpod --shell /bin/bash --uid 33333 --gid 33333 gitpod && \ - usermod -a -G gitpod,couchbase,sudo gitpod && \ - echo 'gitpod ALL=(ALL) NOPASSWD:ALL'>> /etc/sudoers + useradd --no-log-init --create-home --home-dir /home/gitpod --shell /bin/bash --uid 33333 --gid 33333 gitpod && \ + usermod -a -G gitpod,couchbase,sudo gitpod && \ + echo 'gitpod ALL=(ALL) NOPASSWD:ALL'>> /etc/sudoers COPY startcb.sh /opt/couchbase/bin/startcb.sh USER gitpod From 28973b22728703a6436750ab98a040a0561483e7 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 13:45:52 +0100 Subject: [PATCH 2/8] Install python dependencies inside docker image --- .gitpod.Dockerfile | 5 +++-- .gitpod.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 3ea5640..9518900 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -13,9 +13,10 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive &&\ apt-get install -y libssl-dev &&\ apt-get install -y socat sudo &&\ apt-get update &&\ - export PATH="$PATH:/usr/local/bin:/home/gitpod/.local/bin" &&\ + export PATH="$PATH:/usr/local/bin" &&\ export FLASK_APP=src/app &&\ - export FLASK_ENV=development + export FLASK_ENV=development &&\ + python3 -m pip install -r src/requirements.txt RUN addgroup --gid 33333 gitpod && \ useradd --no-log-init --create-home --home-dir /home/gitpod --shell /bin/bash --uid 33333 --gid 33333 gitpod && \ diff --git a/.gitpod.yml b/.gitpod.yml index 3bcd8ae..6599ed1 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -7,7 +7,7 @@ tasks: - name: Log use command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=python-quickstart-repo&source=gitpod' > /dev/null - name: Start app - init: python3 -m pip install -r src/requirements.txt + # init: python3 -m pip install -r src/requirements.txt command: cd src && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 # exposed ports From 9f4d8fc172e9d14546633f166e12e1a09265833f Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 14:29:31 +0100 Subject: [PATCH 3/8] Move pip install into startup command --- .gitpod.Dockerfile | 4 ++-- .gitpod.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 9518900..706b3ec 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -15,8 +15,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive &&\ apt-get update &&\ export PATH="$PATH:/usr/local/bin" &&\ export FLASK_APP=src/app &&\ - export FLASK_ENV=development &&\ - python3 -m pip install -r src/requirements.txt + export FLASK_ENV=development RUN addgroup --gid 33333 gitpod && \ useradd --no-log-init --create-home --home-dir /home/gitpod --shell /bin/bash --uid 33333 --gid 33333 gitpod && \ @@ -24,4 +23,5 @@ RUN addgroup --gid 33333 gitpod && \ echo 'gitpod ALL=(ALL) NOPASSWD:ALL'>> /etc/sudoers COPY startcb.sh /opt/couchbase/bin/startcb.sh +# COPY src/requirements.txt requirements.txt USER gitpod diff --git a/.gitpod.yml b/.gitpod.yml index 6599ed1..4b682f2 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,7 +8,7 @@ tasks: command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=python-quickstart-repo&source=gitpod' > /dev/null - name: Start app # init: python3 -m pip install -r src/requirements.txt - command: cd src && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 + command: cd src && python3 -m pip install -r src/requirements.txt && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 # exposed ports ports: From d8e4f42689fcdc55a90d9a264baf216435bc1d31 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 15:34:02 +0100 Subject: [PATCH 4/8] Fix the pip install --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index 4b682f2..52b886c 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,7 +8,7 @@ tasks: command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=python-quickstart-repo&source=gitpod' > /dev/null - name: Start app # init: python3 -m pip install -r src/requirements.txt - command: cd src && python3 -m pip install -r src/requirements.txt && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 + command: cd src && python3 -m pip install -r requirements.txt && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 # exposed ports ports: From 6b1293d4475102f4376e6d7269b55bf4d102489c Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 16:20:08 +0100 Subject: [PATCH 5/8] Add pip install path to PATH --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index 52b886c..f29f492 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,7 +8,7 @@ tasks: command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=python-quickstart-repo&source=gitpod' > /dev/null - name: Start app # init: python3 -m pip install -r src/requirements.txt - command: cd src && python3 -m pip install -r requirements.txt && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 + command: cd src && python3 -m pip install -r requirements.txt && exoprt PATH=$PATH:/home/gitpod/.local/bin && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 # exposed ports ports: From e79069fbb16c615acdb1f3fbcddce5d5220e9dc1 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 16:26:00 +0100 Subject: [PATCH 6/8] Fix typo --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index f29f492..98941a2 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,7 +8,7 @@ tasks: command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=python-quickstart-repo&source=gitpod' > /dev/null - name: Start app # init: python3 -m pip install -r src/requirements.txt - command: cd src && python3 -m pip install -r requirements.txt && exoprt PATH=$PATH:/home/gitpod/.local/bin && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 + command: cd src && python3 -m pip install -r requirements.txt && export PATH=$PATH:/home/gitpod/.local/bin && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 # exposed ports ports: From 735543f142db9e2744bd54e5a66228063ef0f21e Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 17:44:34 +0100 Subject: [PATCH 7/8] Cleanup the dockerfile --- .gitpod.Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 706b3ec..08e9684 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -23,5 +23,4 @@ RUN addgroup --gid 33333 gitpod && \ echo 'gitpod ALL=(ALL) NOPASSWD:ALL'>> /etc/sudoers COPY startcb.sh /opt/couchbase/bin/startcb.sh -# COPY src/requirements.txt requirements.txt USER gitpod From 504b7213c68dbc5100a047cda02b717559442ab6 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan Date: Wed, 2 Feb 2022 17:52:00 +0100 Subject: [PATCH 8/8] Test with env PIP_USER=yes --- .gitpod.Dockerfile | 3 +++ .gitpod.yml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 08e9684..1d48814 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -24,3 +24,6 @@ RUN addgroup --gid 33333 gitpod && \ COPY startcb.sh /opt/couchbase/bin/startcb.sh USER gitpod +ENV PYTHONUSERBASE=/workspace/.pip-modules +ENV PATH=$PYTHONUSERBASE/bin:$PATH +ENV PIP_USER=yes diff --git a/.gitpod.yml b/.gitpod.yml index 98941a2..3bcd8ae 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -7,8 +7,8 @@ tasks: - name: Log use command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=python-quickstart-repo&source=gitpod' > /dev/null - name: Start app - # init: python3 -m pip install -r src/requirements.txt - command: cd src && python3 -m pip install -r requirements.txt && export PATH=$PATH:/home/gitpod/.local/bin && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 + init: python3 -m pip install -r src/requirements.txt + command: cd src && while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u Administrator:password localhost:8091/pools/default/buckets/)" != "200" ]]; do sleep 5; done && python3 db_init.py && (flask run &) && sleep 1 && socat TCP-LISTEN:8080,fork TCP4:localhost:5000 # exposed ports ports: