Skip to content

Commit 4ca8bfc

Browse files
Merge pull request #264 from dataspread/docker-setup
Add option to deploy locally through Docker
2 parents 13e953c + 1c7fa46 commit 4ca8bfc

13 files changed

Lines changed: 274 additions & 41 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,7 @@ dataspread-ui/npm-debug.log*
9999
dataspread-ui/yarn-debug.log*
100100
dataspread-ui/yarn-error.log*
101101

102+
tomcat_log.txt
103+
102104
#js .env file
103105
dataspread-ui/.env

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Build project source into WAR
2+
FROM maven:3.6-jdk-11-slim AS build
3+
WORKDIR /home/app/src
4+
# Copy project source to docker container
5+
COPY . .
6+
# Build WAR
7+
RUN mvn clean install
8+
9+
# Use tomcat base image
10+
FROM tomcat:9-jre11
11+
12+
# Configure resource in tomcat to communicate with postgres
13+
COPY ./build-web/context.xml /usr/local/tomcat/conf/context.xml
14+
# Copy postgres driver to tomcat
15+
COPY ./build-web/postgresql-9.4.1208.jar /usr/local/tomcat/lib/
16+
17+
# Creates user with access to manager webapp
18+
COPY ./build-web/tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
19+
# Disables network filtering to allow access to manager webapp
20+
COPY ./build-web/manager-context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
21+
22+
# Remove ROOT folder and set DataSpread as ROOT webapp
23+
RUN rm -rf /usr/local/tomcat/webapps/ROOT
24+
# Copies built WAR from previous container
25+
COPY --from=build /home/app/src/webapp/target/DataSpread.war /usr/local/tomcat/webapps/ROOT.war
26+
# Uncomment line below to use working DataSpread WAR
27+
# COPY ./build-web/DataSpread.war /usr/local/tomcat/webapps/ROOT.war
28+
29+
# Start up tomcat server
30+
CMD ["catalina.sh", "run"]

README.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[DataSpread][dataspread-github] is a _spreadsheet-database hybrid system_, with a spreadsheet frontend, and a database backend. Thus, DataSpread inherits the flexibility and ease-of-use of spreadsheets, as well as the scalability and power of databases. A paper describing DataSpread's architecture, design decisions, and optimization can be found [here][dataspread-site]. DataSpread is a multi-year project, supported by the National Science Foundation via award number 1633755.
77

88
### Version
9-
The current version is 0.3.
9+
The current version is 0.5.1.
1010

1111
### Features
1212
DataSpread is built using [PostgreSQL][postgressite] and [ZKSpreadsheet][zksite], an open-source web-based spreadsheet tool.
@@ -33,25 +33,71 @@ In future releases, DataSpread will support SQL on the spreadsheet frontend, alo
3333

3434
## Setup Instructions:
3535

36-
You can directly use DataSpread via our cloud-hosted [site][siteinfo].
36+
You can directly use DataSpread via our cloud-hosted [site][siteinfo] (Temporarily offline).
3737

38-
To host DataSpread locally you can either use one of the pre-build war files, available [here][warlink], or build the war file yourself from the source.
38+
DataSpread can be deployed locally through Docker (recommended) or through Apache Tomcat. To start a new book, import a `csv` file or use the `/sample.csv` provided.
39+
40+
## Docker Method
41+
42+
### Required Software
43+
44+
* [Docker][docker] >= 1.13.0
45+
46+
### Deploying DataSpread locally.
47+
48+
1. Clone the DataSpread repository and go the directory in your terminal. Alternatively, you can download the source as a zip or tar.gz.
49+
50+
2. Install Docker. [Docker][docker] makes it easy to separate applications from underlying infrastructure so setting up and running applications is quick and easy.
51+
52+
3. Start Docker and start the application. It should be accessible at [http://localhost:8080/][install_loc]. Stop the application with `CTRL+C`.
53+
```
54+
docker-compose up
55+
```
56+
57+
58+
### Rebuilding Changes
59+
60+
Any changes to the code can be rebuilt by adding the build tag when starting the application.
61+
```
62+
docker-compose up --build
63+
```
64+
65+
If there are any errors or the docker image needs to be built from scratch, run the following.
66+
```
67+
docker-compose down
68+
docker-compose build --no-cache
69+
docker-compose up
70+
```
71+
72+
### Data Persistance
73+
74+
Data is automatically persisted in a Docker volume across shutdowns. Erase the persisted data by running the following.
75+
```
76+
docker-compose down -v
77+
```
78+
79+
### Additional Information
80+
81+
Docker uses the `/docker-compose.yml` to startup the application. For more information about how the application is deployed, look at `/docker-compose.yml`, `/Dockerfile`, and the files in the `/build-db` and `/build-web` folders.
82+
83+
## Tomcat Method
84+
85+
To host DataSpread locally on Tomcat, you can either use one of the pre-build WAR files, available [here][warlink], or build the WAR file yourself from the source.
3986

4087
### Required Software
4188

4289
* [Java Platform (JDK)][java] >= 8
43-
* [PostgreSQL][posrgres] >= 10.5
90+
* [PostgreSQL][postgres] >= 10.5
4491
* [PostgreSQL JDBC driver][jdbc] = 42.1.4
4592
* [Apache Tomcat][tomcat] >= 8.5.4
4693
* [Apache Maven][maven] >= 3.5.0
4794
* [NodeJS][node] >= 10.9
4895

49-
50-
### Building Instructions (To generate a war file)
96+
### Building Instructions (To generate a WAR file)
5197

5298
1. Clone the DataSpread repository. Alternatively, you can download the source as a zip or tar.gz.
5399

54-
2. Use maven to build the `war` file using the following command. After the build completes the war is available at `webapp/target/DataSpread.war`.
100+
2. Use maven to build the `war` file using the following command. After the build completes, the WAR is available at `webapp/target/DataSpread.war`.
55101

56102
```
57103
mvn clean install
@@ -81,7 +127,7 @@ To host DataSpread locally you can either use one of the pre-build war files, av
81127

82128
5. Copy `postgresql-42.1.4.jar` (Download from [here][jdbc]) to `lib` folder under `TOMCAT_HOME`. It is crucial to have the exact version of this file.
83129

84-
6. Deploy the war file within Tomcat. This can be done via Tomcat's web interface or by manually copying the war file in the `webapps` folder under `TOMCAT_HOME`.
130+
6. Deploy the WAR file within Tomcat as the root application. This can be done via Tomcat's web interface by undeploying any application located at `/` and deploying the WAR file with the context path `/`. To do this manually, delete the `webapps/ROOT` folder under `TOMCAT_HOME` while the application is not running, copy the WAR file to the `webapps` folder, and rename it to `ROOT.war`.
85131

86132
7. Now you are ready to run the program. Visit the url where Tomcat is installed. It will be typically [http://localhost:8080/][install_loc] for a local install.
87133

@@ -94,11 +140,11 @@ MIT
94140
[tomcat_install]: https://www.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html
95141
[postgre_install]: https://wiki.postgresql.org/wiki/Detailed_installation_guides
96142
[Postgres.app]: http://postgresapp.com
97-
[jdbc]: http://central.maven.org/maven2/org/postgresql/postgresql/42.1.4/postgresql-42.1.4.jar
143+
[jdbc]: https://repo1.maven.org/maven2/org/postgresql/postgresql/42.1.4/postgresql-42.1.4.jar
98144
[ant]: https://ant.apache.org/bindownload.cgi
99145
[tomcat]: http://tomcat.apache.org/download-80.cgi
100146
[java]: http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
101-
[posrgres]:https://www.postgresql.org/download/
147+
[postgres]:https://www.postgresql.org/download/
102148
[siteinfo]: http://kite.cs.illinois.edu:8080
103149
[zksite]: https://www.zkoss.org/product/zkspreadsheet
104150
[postgressite]: https://www.postgresql.org/
@@ -107,4 +153,4 @@ MIT
107153
[dataspread-site]: http://data-people.cs.illinois.edu/dataspread.pdf
108154
[maven]: https://maven.apache.org/install.html
109155
[node]: https://nodejs.org/en/download/current/
110-
156+
[docker]: https://www.docker.com/products/docker-desktop

build-db/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use postgres 10.14
2+
FROM postgres:10.14
3+
4+
# Creates database with name "dataspread_db" and superuser with username "admin" and password "password"
5+
# Any changes to these values should also be made to the "jdbc/ibd" Resource in context.xml
6+
ENV POSTGRES_DB dataspread_db
7+
ENV POSTGRES_USER admin
8+
ENV POSTGRES_PASSWORD password

build-web/DataSpread.war

44.4 MB
Binary file not shown.

build-web/context.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<!-- The contents of this file will be loaded for each web application -->
19+
<Context>
20+
21+
<!-- Default set of monitored resources. If one of these changes, the -->
22+
<!-- web application will be reloaded. -->
23+
<WatchedResource>WEB-INF/web.xml</WatchedResource>
24+
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
25+
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
26+
27+
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
28+
<!--
29+
<Manager pathname="" />
30+
-->
31+
32+
<!-- TEMPLATE for db resource. Resource required for tomcat to communicate with postgres.
33+
<Resource name="jdbc/ibd" auth="Container"
34+
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
35+
url="jdbc:postgresql://<db_docker_service_name>:5432/<database_name>"
36+
username="<username>" password="<password>"
37+
maxTotal="20" maxIdle="10" maxWaitMillis="-1" defaultAutoCommit="false"
38+
accessToUnderlyingConnectionAllowed="true"/>
39+
-->
40+
<Resource name="jdbc/ibd" auth="Container"
41+
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
42+
url="jdbc:postgresql://app-db:5432/dataspread_db"
43+
username="admin" password="password"
44+
maxTotal="20" maxIdle="10" maxWaitMillis="-1" defaultAutoCommit="false"
45+
accessToUnderlyingConnectionAllowed="true"/>
46+
</Context>

build-web/manager-context.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
context.xml included in the manager webapp i.e. tomcat/webapps/manager/META-INF
4+
disables filtering of non-localhost traffic to manager webapp
5+
-->
6+
7+
<!--
8+
Licensed to the Apache Software Foundation (ASF) under one or more
9+
contributor license agreements. See the NOTICE file distributed with
10+
this work for additional information regarding copyright ownership.
11+
The ASF licenses this file to You under the Apache License, Version 2.0
12+
(the "License"); you may not use this file except in compliance with
13+
the License. You may obtain a copy of the License at
14+
15+
http://www.apache.org/licenses/LICENSE-2.0
16+
17+
Unless required by applicable law or agreed to in writing, software
18+
distributed under the License is distributed on an "AS IS" BASIS,
19+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
See the License for the specific language governing permissions and
21+
limitations under the License.
22+
-->
23+
24+
<Context antiResourceLocking="false" privileged="true" >
25+
<!-- UNCOMMENT TO DISABLE NON-LOCALHOST TRAFFIC TO MANAGER -->
26+
<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
27+
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
28+
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
29+
</Context>

build-web/postgresql-9.4.1208.jar

633 KB
Binary file not shown.

build-web/tomcat-users.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<tomcat-users xmlns="http://tomcat.apache.org/xml"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
21+
version="1.0">
22+
<!-- Change username and password as needed for access to manager webapp -->
23+
<role rolename="manager-gui"/>
24+
<role rolename="manager-script"/>
25+
<user username="admin" password="admin" roles="manager-gui,manager-script"/>
26+
</tomcat-users>

0 commit comments

Comments
 (0)