Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensures that were using watchdog and have enough watches available #9688

Merged
merged 2 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV DEBIAN_FRONTEND=noninteractive

ARG PACKAGES="libpq-dev libxml2 libxslt1-dev libfreetype6 libjpeg-dev libmaxminddb-dev bash git tar gzip inkscape libmagic-dev"
# Define packages to be installed
ARG PACKAGES="libpq-dev libxml2 libxslt1-dev libfreetype6 libjpeg-dev libmaxminddb-dev bash git tar gzip inkscape libmagic-dev build-essential python-dev libssl-dev python3-dev libsecp256k1-dev libsodium-dev python3-pip"
ARG BUILD_DEPS="gcc g++ curl postgresql libxml2-dev libxslt-dev libfreetype6 libffi-dev libjpeg-dev autoconf automake libtool make dos2unix libvips libvips-dev"
ARG CHROME_DEPS="fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libcurl3-gnutls libdrm2 libexpat1 libgbm1 libglib2.0-0 libnspr4 libgtk-3-0 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 libxshmfence1 xdg-utils"
ARG CYPRESS_DEPS="libgtk2.0-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libxtst6 xauth xvfb"
Expand All @@ -16,6 +17,8 @@ RUN add-apt-repository ppa:inkscape.dev/stable
RUN apt-get update

# Install general dependencies.
RUN add-apt-repository universe
RUN apt-get update
RUN apt-get install -y $PACKAGES
RUN apt-get update --fix-missing
RUN apt-get install -y $BUILD_DEPS --fix-missing
Expand All @@ -30,14 +33,8 @@ RUN dpkg -i google-chrome-stable_current_amd64.deb
# Install cypress dependencies
RUN apt-get install -y $CYPRESS_DEPS

RUN apt-get install -y libsodium-dev

RUN add-apt-repository universe
RUN apt-get update
RUN apt-get install -y python3-pip

# Move to /code dir and copy in working dir content
WORKDIR /code

COPY dist/* ./

# GeoIP2 Data Files
Expand All @@ -52,31 +49,36 @@ RUN mkdir -p /usr/share/GeoIP/ && \
# Upgrade package essentials.
RUN pip3 install --upgrade pip==20.0.2 setuptools wheel dumb-init pipenv

# Install pip packages
COPY requirements/ /code/
RUN apt-get update
RUN apt-get install -y build-essential libssl-dev python3-dev
RUN apt-get install -y libsecp256k1-dev
RUN pip3 install --upgrade -r test.txt

# Copy over docker-command (start-up script)
COPY bin/docker-command.bash /bin/docker-command.bash
RUN dos2unix /bin/docker-command.bash

# Copy over code directory
COPY app/ /code/app/

# Install yarn and set node version
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install -y yarn
RUN yarn global add n
RUN n stable

# Increase number of watched files (524288 is the max we can set this to)
RUN echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf

# Init
EXPOSE 9222
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
CMD ["bash", "/bin/docker-command.bash"]

# Save image
ARG BUILD_DATETIME
ARG SHA1

LABEL co.gitcoin.description="Gitcoin web application image" \
co.gitcoin.documentation="https://github.com/gitcoinco/web/blob/master/docs/RUNNING_LOCALLY_DOCKER.md" \
co.gitcoin.licenses="AGPL-3.0" \
Expand All @@ -85,3 +87,4 @@ LABEL co.gitcoin.description="Gitcoin web application image" \
co.gitcoin.image.source="https://github.com/gitcoinco/web" \
co.gitcoin.image.title="Gitcoin Web" \
co.gitcoin.image.created=$BUILD_DATETIME

12 changes: 10 additions & 2 deletions app/app/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
################################################################################
# BASIC PARAMS
################################################################################

CACHE_URL=dbcache://my_cache_table
REDIS_URL=rediscache://redis:6379/0?client_class=django_redis.client.DefaultClient
CACHEOPS_REDIS=redis://redis:6379/0
Expand All @@ -14,6 +13,16 @@ DATABASE_URL=psql://postgres:postgres@db:5432/postgres
# DATABASE_URL=psql://gitcoin_user:password@localhost:5432/gitcoin
DEBUG=on

################################################################################
# DOCKER PROVISIONING PARAMS
################################################################################
# FORCE_PROVISION=on
# DISABLE_PROVISION=on
# DISABLE_INITIAL_CACHETABLE=on
# DISABLE_INITIAL_COLLECTSTATIC=on
# DISABLE_INITIAL_LOADDATA=on
# DISABLE_INITIAL_MIGRATE=on

################################################################################
# ADVANCED NOTIFICATION PARAMS
################################################################################
Expand Down Expand Up @@ -47,7 +56,6 @@ INFURA_USE_V3=True

SUPRESS_DEBUG_TOOLBAR=1


SENDGRID_API_KEY=
CONTACT_EMAIL=

Expand Down
3 changes: 3 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@
SITE_ID = env.int('SITE_ID', default=1)
WSGI_APPLICATION = env('WSGI_APPLICATION', default='app.wsgi.application')

# Explicity use watchdog for inotify
RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'watchdog'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
Expand Down
5 changes: 3 additions & 2 deletions bin/docker-command.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ GC_WEB_WORKER=${GC_WEB_WORKER_TYPE:-runserver_plus}

# General / Overrides
FORCE_PROVISION=${FORCE_PROVISION:-'off'}
DISABLE_PROVISION=${DISABLE_PROVISION:-'off'}
FORCE_GET_PRICES=${FORCE_GET_PRICES:-'off'}

cd app || exit 1
Expand Down Expand Up @@ -40,7 +41,7 @@ if [ "$GC_WEB_WORKER" = "runserver_plus" ]; then
fi

# Provision the Django test environment.
if [ ! -f /provisioned ] || [ "$FORCE_PROVISION" = "on" ];
if [ "$DISABLE_PROVISION" != "on" ] && [ ! -f /provisioned ] || [ "$FORCE_PROVISION" = "on" ];
then
echo "First run - Provisioning the local development environment..."
if [ "$DISABLE_INITIAL_CACHETABLE" != "on" ]; then
Expand Down Expand Up @@ -85,7 +86,7 @@ then
echo "Provisioning complete!"
else
# Build assets using bundle and webpack
if [ "$DISABLE_WEBPACK_ASSETS" != "on" && "$ENV" != "prod" ]; then
if [ "$DISABLE_WEBPACK_ASSETS" != "on" ] && [ "$ENV" != "prod" ]; then
python3 manage.py bundle && yarn run webpack &
fi
fi
Expand Down