Skip to content

Commit 2624e30

Browse files
authored
Fixes arising from deployment (#49)
* Set timer variable to null before access * Use https bokeh for CORS reasons * Tidy up docker-compose file * Add .env to gitignore for future updates * Use simple node http-server for deployment * Use gunicorn for deployment * Remove yarn linting in lieu of pre-commit/prettier workflow * Rename docker-compose service in CI * Add gunicorn as a direct dev dependency * Use correct URL for e2e testing * Explicitly tell http-server to use localhost for e2e tests - More attempts to force http-server to run - Revert change to http-server options to not use localhost * Daemonize docker-compose * Install tree within API docker image * Set MONGO_URI in docker-compose directly * Remove minor versions of external GH actions and update Pipfile.lock
1 parent d30efb4 commit 2624e30

File tree

10 files changed

+371
-332
lines changed

10 files changed

+371
-332
lines changed

.docker/app_dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM node:15.14.0-stretch
22
SHELL ["/bin/bash", "--login", "-c"]
33

44
WORKDIR /app
5-
CMD ["yarn", "serve"]
5+
RUN npm install -g http-server
66

77
# copy repo contents and install deps
88
#
@@ -11,3 +11,6 @@ COPY webapp/package.json /app/
1111
RUN yarn install
1212

1313
COPY webapp /app
14+
15+
RUN yarn build
16+
CMD [ "http-server", "dist", "--port", "8081" ]

.docker/server_dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
FROM python:3.8
22
SHELL ["/bin/bash", "--login", "-c"]
3+
RUN apt update && apt install -y tree && apt clean
34

45
# Copy all server code into workdir
56
WORKDIR /app
67
COPY ./pydatalab/ /app
78

89
# Install Pipenv and use it to grab dependencies
910
RUN pip install pipenv
10-
RUN pipenv install --deploy
11+
RUN pipenv install --deploy --dev
1112

1213
# Run flask server
13-
CMD ["pipenv", "run", "python", "pydatalab/main.py"]
14+
CMD ["pipenv", "run", "gunicorn", "-w", "2", "--error-logfile", "logs/pydatalab_error.log", "--access-logfile", "logs/pydatalab_access.log", "-b", "0.0.0.0:5001", "pydatalab.main:create_app()"]

.github/workflows/ci.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2.3.4
14+
- uses: actions/checkout@v2
1515

1616
- name: Set up Python 3.9
17-
uses: actions/setup-python@v2.2.2
17+
uses: actions/setup-python@v2
1818
with:
1919
python-version: 3.9
2020

@@ -43,10 +43,10 @@ jobs:
4343
python-version: [3.8, 3.9]
4444

4545
steps:
46-
- uses: actions/checkout@v2.3.4
46+
- uses: actions/checkout@v2
4747

4848
- name: Set up Python ${{ matrix.python-version }}
49-
uses: actions/setup-python@v2.2.2
49+
uses: actions/setup-python@v2
5050
with:
5151
python-version: ${{ matrix.python-version }}
5252

@@ -63,28 +63,24 @@ jobs:
6363
6464
- name: Upload coverage to Codecov
6565
if: matrix.python-version == 3.8 && github.repository == 'the-grey-group/datalabvue'
66-
uses: codecov/codecov-action@v2.0.2
66+
uses: codecov/codecov-action@v2
6767

6868
webapp:
6969
name: Test the webapp
7070
runs-on: ubuntu-latest
7171

7272
steps:
73-
- uses: actions/checkout@v2.3.4
73+
- uses: actions/checkout@v2
7474

7575
- name: Set up Node
7676
uses: actions/setup-node@v2
7777
with:
78-
node-version: "14"
78+
node-version: "15.14"
7979

8080
- name: Install web app
8181
working-directory: ./webapp
8282
run: yarn install
8383

84-
- name: Lint web app
85-
working-directory: ./webapp
86-
run: yarn lint --no-fix --max-warnings 0
87-
8884
- name: Unit and Component test web app
8985
working-directory: ./webapp
9086
run: yarn test:unit
@@ -97,19 +93,17 @@ jobs:
9793
run: docker-compose build app
9894

9995
- name: Build the Docker server image
100-
run: docker-compose build server
96+
run: docker-compose build api
10197

10298
- name: Build the Docker mongo image
10399
run: docker-compose build mongo
104100

105101
- name: Start Docker images
106102
run: |
107103
docker-compose up --abort-on-container-exit &
108-
# If there are no build errors after 1 minute, then exit successfully.
109-
# In future, some additional tests will run here instead.
110104
sleep 60
111105
exit 0
112106
113107
- name: Run end-to-end tests
114108
working-directory: ./webapp
115-
run: yarn test:e2e --headless --url http://localhost:8080
109+
run: yarn test:e2e --headless --url http://localhost:8081

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ coverage.xml
5656

5757
# Envs
5858
.python-version
59+
.env
5960
.venv
6061
.env.local
6162
env/

docker-compose.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,26 @@ services:
66
build:
77
context: .
88
dockerfile: .docker/app_dockerfile
9+
depends_on:
10+
- api
911
volumes:
10-
- ./logs:/var/logs/mongod/
11-
12+
- ./logs:/app/logs/
1213
ports:
13-
- "8080:8080"
14+
- "8081:8081"
1415

15-
server:
16+
api:
1617
restart: always
1718
build:
1819
context: .
1920
dockerfile: .docker/server_dockerfile
2021
depends_on:
2122
- mongo
2223
volumes:
23-
- sockets:/tmp/
2424
- ./logs:/app/logs/
25-
2625
ports:
2726
- "5001:5001"
27+
environment:
28+
- PYDATALAB_MONGO_URI=mongodb://mongo:27017/datalabvue
2829

2930
mongo:
3031
restart: always
@@ -33,9 +34,7 @@ services:
3334
dockerfile: .docker/mongo_dockerfile
3435
command: ["mongod", "-f", "/etc/mongod.conf"]
3536
volumes:
36-
- sockets:/tmp/
3737
- ./logs:/var/logs/mongod/
38-
3938
ports:
4039
- "27017:27017"
4140

pydatalab/Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pytest-cov = "*"
2525
pytest-dependency = "*"
2626
pre-commit = "*"
2727
mongomock = "*"
28+
gunicorn = "*"
2829

2930
[requires]
3031
python_version = "3"

pydatalab/Pipfile.lock

Lines changed: 338 additions & 303 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pydatalab/pydatalab/routes/remotes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def list_remote_directories_cached():
2323
for d in all_directory_structures
2424
if d["last_updated"]
2525
]
26-
if len(last_update_datetimes):
26+
27+
seconds_since_last_update = None
28+
if last_update_datetimes:
2729
print("Last updates from caches:")
2830
print(last_update_datetimes)
2931
seconds_since_last_update = (

webapp/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
src="https://cdn.bokeh.org/bokeh/release/bokeh-2.2.3.min.js"
1111
crossorigin="anonymous"
1212
></script>
13-
<script src="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js"></script>
13+
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js"></script>
1414
</head>
1515
<body>
1616
<noscript>

webapp/src/components/FileSelectModal.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ export default {
9999
console.log(
100100
`loadCachedTree received, ${response_json.seconds_since_last_update} seconds out of date:`
101101
);
102-
if (response_json.seconds_since_last_update > 3600) {
102+
if (
103+
response_json.seconds_since_last_update == null ||
104+
response_json.seconds_since_last_update > 3600
105+
) {
103106
console.log("cache more than 1 hr out of date. Fetching new sample tree");
104107
this.fetchRemoteTree();
105108
}

0 commit comments

Comments
 (0)