Skip to content

Commit e612fe3

Browse files
authored
Merge pull request #194 from taniwallach/update-base-add-docker-compose-yml
Updates and fixes for the devstack setup.
2 parents a091bed + 1756a08 commit e612fe3

File tree

5 files changed

+100
-16
lines changed

5 files changed

+100
-16
lines changed

Dockerfile

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
FROM edxops/xenial-common:latest
1+
FROM edxops/focal-common:latest
22
RUN apt-get update && apt-get install -y \
33
gettext \
44
lib32z1-dev \
55
libjpeg62-dev \
6-
libxslt-dev \
7-
libz-dev \
8-
python3.5 \
6+
libxslt1-dev \
7+
zlib1g-dev \
8+
python3 \
99
python3-dev \
1010
python3-pip && \
1111
pip3 install --upgrade pip setuptools && \
1212
rm -rf /var/lib/apt/lists/*
1313

14-
1514
COPY . /usr/local/src/xblock-sdk
1615
WORKDIR /usr/local/src/xblock-sdk
1716

18-
RUN pip install -r /usr/local/src/xblock-sdk/requirements/dev.txt
17+
RUN ln -s /usr/bin/python3.8 /usr/bin/python && \
18+
/usr/bin/python3 -m pip install --upgrade pip && \
19+
pip install -r /usr/local/src/xblock-sdk/requirements/dev.txt
1920

20-
RUN curl -sL https://deb.nodesource.com/setup_10.x -o /tmp/nodejs-setup
21-
RUN /bin/bash /tmp/nodejs-setup
22-
RUN rm /tmp/nodejs-setup
23-
RUN apt-get -y install nodejs
24-
RUN echo $PYTHONPATH
21+
RUN curl -sL https://deb.nodesource.com/setup_14.x -o /tmp/nodejs-setup && \
22+
/bin/bash /tmp/nodejs-setup && \
23+
rm /tmp/nodejs-setup && \
24+
apt-get -y install nodejs && \
25+
echo $PYTHONPATH && \
26+
make install
2527

26-
RUN make install
2728
EXPOSE 8000
2829
ENTRYPOINT ["python3", "manage.py"]
2930
CMD ["runserver", "0.0.0.0:8000"]

Makefile

+17-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,23 @@ selfcheck: ## check that the Makefile is well-formed
8787
@echo "The Makefile is well-formed."
8888

8989
docker_build:
90-
docker build . -t "openedx/xblock-sdk:latest"
90+
docker-compose build
91+
92+
# devstack-themed shortcuts
93+
dev.up: # Starts all containers
94+
docker-compose up -d
95+
96+
dev.up.build:
97+
docker-compose up -d --build
98+
99+
dev.down: # Kills containers and all of their data that isn't in volumes
100+
docker-compose down
101+
102+
dev.stop: # Stops containers so they can be restarted
103+
docker-compose stop
104+
105+
app-shell: # Run bash in the container as root
106+
docker exec -u 0 -it edx.devstack.xblock-sdk bash
91107

92108
travis_docker_auth:
93109
echo "$$DOCKER_PASSWORD" | docker login -u "$$DOCKER_USERNAME" --password-stdin

README.rst

+49-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ This code runs on Python 3.5 or newer.
2020

2121
$ sudo apt-get install python-dev libxml2-dev libxslt-dev lib32z1-dev libjpeg62-dev
2222

23+
Note: Debian 10 needs libjpeg62-turbo-dev instead of libjpeg62-dev.
24+
2325
#. Get a local copy of this repo.
2426

2527
#. Create and activate a virtualenv to work in.
@@ -37,21 +39,65 @@ This code runs on Python 3.5 or newer.
3739
Docker
3840
------
3941

40-
Alternatively, you can build and run the xblock-sdk in Docker.
42+
Alternatively, you can build and run the xblock-sdk in Docker (we are using docker-compose which
43+
can be installed as explained at https://docs.docker.com/compose/install/)
4144

4245
After cloning this repository locally, go into the repository directory and build the Docker image::
4346

44-
$ docker build -t xblock-sdk .
47+
$ make docker_build
48+
49+
or manually run
50+
51+
$ docker-compose build
4552

4653
You can then run the locally-built version using the following command::
4754

48-
$ docker run -d -p 8000:8000 --name xblock-sdk xblock-sdk
55+
$ make dev.up
56+
57+
or manually run::
58+
59+
$ docker-compose up -d
60+
61+
and stop the container (without removing data) by::
62+
63+
$ make dev.stop
64+
65+
or manually run::
66+
67+
$ docker-compose stop
68+
69+
Note, using::
70+
71+
$ make dev.down
72+
73+
or::
74+
75+
$ docker-compose down
76+
77+
will shut down the container and delete non-persistant data.
78+
79+
On the first startup run the following command to create the SQLite database.
80+
(Otherwise you will get an error no such table: workbench_xblockstate.)
81+
82+
Command::
83+
84+
$ docker container exec -it edx.devstack.xblock-sdk python3.8 manage.py migrate
4985

5086
You should now be able to access the XBlock SDK environment in your browser at http://localhost:8000
5187

88+
You can open a bash shell in the running container by using::
89+
90+
$ make app-shell
91+
92+
or::
93+
94+
$ docker container exec -it edx.devstack.xblock-sdk bash
95+
5296
Testing
5397
--------
5498

99+
If using Docker, all these commands need to be run inside the xblock-sdk container.
100+
55101
Testing is done via tox to test all supported versions:
56102

57103
#. Create and activate a virtualenv to work in.

docker-compose.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.5'
2+
services:
3+
xblock_sdk:
4+
image: xblock-sdk
5+
container_name: edx.devstack.xblock-sdk
6+
7+
build: .
8+
9+
volumes:
10+
# Provide a persistant location for the SQLite database
11+
- xblock-var:/usr/local/src/xblock-sdk/var
12+
13+
hostname: localhost
14+
ports:
15+
- "8000:8000"
16+
17+
# Persistant storage volumes:
18+
volumes:
19+
# For the SQLite database
20+
xblock-var:

manage.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
"""Manage.py file for XBlock"""
23
import os
34
import sys

0 commit comments

Comments
 (0)