Skip to content

Commit 7983512

Browse files
committed
Add compose setup
1 parent aec4bfa commit 7983512

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed

Dockerfile

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,38 @@
1-
FROM python:3.6
1+
FROM gladiatr72/just-tini:latest as tini
2+
3+
FROM revolutionsystems/python:3.6.9-wee-optimized-lto
24

35
LABEL Description="Image for simpl-calc-ui" Vendor="Wharton" Version="0.1.0"
46

57
ENV PYTHONUNBUFFERED 1
68

7-
ENV DOCKERIZE_VERSION v0.2.0
8-
9-
RUN mkdir -p /root/.ssh \
10-
&& chmod 700 /root/.ssh \
11-
&& echo "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
9+
RUN mkdir /code
10+
RUN mkdir /code/staticfiles
11+
RUN mkdir /code/staticfiles/webpack_bundles
1212

13-
ADD keys/wharton_ll /root/.ssh/
14-
RUN chmod 600 /root/.ssh/wharton_ll
13+
WORKDIR /code
1514

16-
RUN apt-get update && apt-get install -y wget \
17-
&& wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
18-
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
19-
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
15+
COPY --from=tini /tini /tini
2016

2117
RUN pip install --upgrade pip
2218

23-
RUN mkdir /code
24-
WORKDIR /code
25-
ADD . /code/
19+
ADD ./requirements.txt /code/
20+
RUN pip install -r /code/requirements.txt
2621

27-
ENV PYTHONPATH /code:$PYTHONPATH
22+
# Setup NodeJS
23+
RUN set -ex && apt-get update && apt-get -y install curl software-properties-common
24+
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
25+
RUN apt-get -y install nodejs
2826

29-
RUN eval "$(ssh-agent -s)" \
30-
&& ssh-add /root/.ssh/wharton_ll \
31-
&& pip install -r /code/requirements.txt \
32-
&& pip install -r /code/requirements_dev.txt
27+
ADD ./package.json /code/
28+
RUN npm install
3329

34-
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
35-
RUN apt-get install -y nodejs \
36-
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
30+
ADD . /code/
3731

38-
RUN eval "$(ssh-agent -s)" \
39-
&& ssh-add /root/.ssh/wharton_ll \
40-
&& npm install --progress=false \
41-
&& npm dedupe --progress=false \
42-
&& npm run compile --production \
43-
&& rm -rf node_modules
32+
#RUN NODE_ENV=production npm run compile
4433

45-
ENV MODEL_SERVICE_WS ws://model:8080/ws
34+
ENV PYTHONPATH /code:$PYTHONPATH
35+
ENV MODEL_SERVICE_WS ws://localhost:8080/ws
4636

4737
EXPOSE 8000
48-
CMD python check_modelservice.py && gunicorn simpl_calc_ui.wsgi -b 0.0.0.0:8000
38+
CMD /code/bootstrap.sh

compose-bootstrap.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
python manage.py migrate --no-input
3+
python manage.py collectstatic --no-input
4+
5+
npm install
6+
npm rebuild node-sass
7+
npm run start &
8+
python manage.py runserver 0.0.0.0:8000

docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: '3'
2+
3+
services:
4+
ui:
5+
build:
6+
context: .
7+
networks:
8+
- simpl
9+
volumes:
10+
- .:/code
11+
ports:
12+
- "8000:8000"
13+
command: /code/compose-bootstrap.sh
14+
environment:
15+
- DJANGO_SETTINGS_MODULE=simpl_calc_ui.settings
16+
- MODEL_SERVICE_WS=ws://localhost:8080/ws
17+
- SIMPL_GAMES_URL=http://api:8000/apis/
18+
stop_signal: SIGKILL
19+
20+
networks:
21+
simpl:
22+
external:
23+
name: simpl-games-api_simpl

0 commit comments

Comments
 (0)