Skip to content

Commit b6b0143

Browse files
add docker support
1 parent e27624b commit b6b0143

7 files changed

Lines changed: 57 additions & 4 deletions

File tree

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SECRET_KEY=
2+
DEBUG=True
3+
4+
## Super-User Credentials
5+
SUPER_USER_NAME =
6+
SUPER_USER_PASSWORD =
7+
SUPER_USER_EMAIL =

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.8.5-alpine
2+
3+
RUN pip install --upgrade pip
4+
RUN pip install tzdata
5+
RUN apk update && apk add gcc musl-dev
6+
RUN apk add --no-cache bash coreutils grep sed
7+
8+
9+
COPY ./requirements.txt .
10+
RUN pip install -r requirements.txt
11+
12+
COPY . /app
13+
14+
WORKDIR /app
15+
16+
COPY ./init.sh /
17+
ENTRYPOINT ["sh", "/init.sh"]

bundler/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# SECURITY WARNING: don't run with debug turned on in production!
3131
DEBUG = True
3232

33-
ALLOWED_HOSTS = []
33+
ALLOWED_HOSTS = ['127.0.0.1', '0.0.0.0', 'localhost']
3434

3535

3636
# Application definition
@@ -123,8 +123,9 @@
123123
# https://docs.djangoproject.com/en/4.1/howto/static-files/
124124

125125
STATIC_URL = "static/"
126+
STATIC_ROOT = BASE_DIR / "static"
126127

127128
# Default primary key field type
128129
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
129130

130-
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
131+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

bundler/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"""
1616
from django.contrib import admin
1717
from django.urls import path
18+
from django.conf import settings
19+
from django.conf.urls.static import static
1820
from bundler import bundler
1921
from bundler import paymaster
2022
from bundler import explorer
@@ -25,4 +27,4 @@
2527
path("jsonrpc/bundler", bundler.jsonrpc),
2628
path("jsonrpc/paymaster", paymaster.jsonrpc),
2729
path("jsonrpc/explorer", explorer.jsonrpc),
28-
]
30+
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3.7'
2+
3+
services:
4+
django_gunicorn:
5+
volumes:
6+
- static:/static
7+
env_file:
8+
- .env
9+
build:
10+
context: .
11+
ports:
12+
- "8001:8001"
13+
14+
volumes:
15+
static:

init.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
python manage.py makemigrations bundler
4+
python manage.py migrate
5+
python manage.py loaddata bundler/tokenSeed.json
6+
python manage.py collectstatic --no-input
7+
8+
DJANGO_SUPERUSER_PASSWORD=$SUPER_USER_PASSWORD python manage.py createsuperuser --username $SUPER_USER_NAME --email $SUPER_USER_EMAIL --noinput
9+
10+
gunicorn bundler.wsgi:application --bind 0.0.0.0:8001

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ web3==5.31.0
66
django==4.1.1
77
eth_abi==2.2.0
88
gnosis==0.1.1
9-
safe-eth-py==4.5.1
9+
safe-eth-py==4.5.1
10+
gunicorn==20.0.4

0 commit comments

Comments
 (0)