Skip to content

Commit d8f367c

Browse files
authored
Merge pull request DSpace#2189 from tdonohue/docker_cleanup
Minor docker / compose updates based on recent changes to backend
2 parents b7bd6ef + 113703f commit d8f367c

4 files changed

Lines changed: 63 additions & 23 deletions

File tree

Dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details
33

44
FROM node:18-alpine
5-
WORKDIR /app
6-
ADD . /app/
7-
EXPOSE 4000
85

96
# Ensure Python and other build tools are available
107
# These are needed to install some node modules, especially on linux/arm64
118
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
129

10+
WORKDIR /app
11+
ADD . /app/
12+
EXPOSE 4000
13+
1314
# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com
1415
# See, for example https://github.com/yarnpkg/yarn/issues/5540
1516
RUN yarn install --network-timeout 300000
1617

18+
# When running in dev mode, 4GB of memory is required to build & launch the app.
19+
# This default setting can be overridden as needed in your shell, via an env file or in docker-compose.
20+
# See Docker environment var precedence: https://docs.docker.com/compose/environment-variables/envvars-precedence/
21+
ENV NODE_OPTIONS="--max_old_space_size=4096"
22+
1723
# On startup, run in DEVELOPMENT mode (this defaults to live reloading enabled, etc).
1824
# Listen / accept connections from all IP addresses.
1925
# NOTE: At this time it is only possible to run Docker container in Production mode
20-
# if you have a public IP. See https://github.com/DSpace/dspace-angular/issues/1485
26+
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
27+
ENV NODE_ENV development
2128
CMD yarn serve --host 0.0.0.0

docker/README.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@
66
If you wish to run DSpace on Docker in production, we recommend building your own Docker images. You are welcome to borrow ideas/concepts from the below images in doing so. But, the below images should not be used "as is" in any production scenario.
77
***
88

9-
## 'Dockerfile' in root directory
9+
## Overview
10+
The scripts in this directory can be used to start the DSpace User Interface (frontend) in Docker.
11+
Optionally, the backend (REST API) might also be started in Docker.
12+
13+
For additional options/settings in starting the backend (REST API) in Docker, see the Docker Compose
14+
documentation for the backend: https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/README.md
15+
16+
## Root directory
17+
18+
The root directory of this project contains all the Dockerfiles which may be referenced by
19+
the Docker compose scripts in this 'docker' folder.
20+
21+
### Dockerfile
22+
1023
This Dockerfile is used to build a *development* DSpace 7 Angular UI image, published as 'dspace/dspace-angular'
1124

1225
```
@@ -20,6 +33,8 @@ Admins to our DockerHub repo can manually publish with the following command.
2033
docker push dspace/dspace-angular:dspace-7_x
2134
```
2235

36+
### Dockerfile.dist
37+
2338
The `Dockerfile.dist` is used to generate a *production* build and runtime environment.
2439

2540
```bash
@@ -29,7 +44,7 @@ docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-7_x-dist .
2944

3045
A default/demo version of this image is built *automatically*.
3146

32-
## docker directory
47+
## 'docker' directory
3348
- docker-compose.yml
3449
- Starts DSpace Angular with Docker Compose from the current branch. This file assumes that a DSpace 7 REST instance will also be started in Docker.
3550
- docker-compose-rest.yml
@@ -54,25 +69,41 @@ docker-compose -f docker/docker-compose.yml build
5469

5570
## To start DSpace (REST and Angular) from your branch
5671

72+
This command provides a quick way to start both the frontend & backend from this single codebase
5773
```
5874
docker-compose -p d7 -f docker/docker-compose.yml -f docker/docker-compose-rest.yml up -d
5975
```
6076

77+
Keep in mind, you may also start the backend by cloning the 'DSpace/DSpace' GitHub repository separately. See the next section.
78+
79+
6180
## Run DSpace REST and DSpace Angular from local branches.
81+
82+
This section assumes that you have clones *both* the 'DSpace/DSpace' and 'DSpace/dspace-angular' GitHub
83+
repositories. When both are available locally, you can spin up both in Docker and have them work together.
84+
6285
_The system will be started in 2 steps. Each step shares the same docker network._
6386

64-
From DSpace/DSpace (build as needed)
87+
From 'DSpace/DSpace' clone (build first as needed):
6588
```
6689
docker-compose -p d7 up -d
6790
```
6891

69-
From DSpace/DSpace-angular
92+
NOTE: More detailed instructions on starting the backend via Docker can be found in the [Docker Compose instructions for the Backend](https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/README.md).
93+
94+
From 'DSpace/dspace-angular' clone (build first as needed)
7095
```
7196
docker-compose -p d7 -f docker/docker-compose.yml up -d
7297
```
7398

99+
At this point, you should be able to access the UI from http://localhost:4000,
100+
and the backend at http://localhost:8080/server/
101+
74102
## Run DSpace Angular dist build with DSpace Demo site backend
75103

104+
This allows you to run the Angular UI in *production* mode, pointing it at the demo backend
105+
(https://api7.dspace.org/server/).
106+
76107
```
77108
docker-compose -f docker/docker-compose-dist.yml pull
78109
docker-compose -f docker/docker-compose-dist.yml build
@@ -104,9 +135,10 @@ Load assetstore content and trigger a re-index of the repository
104135
docker-compose -p d7 -f docker/cli.yml -f docker/cli.assetstore.yml run --rm dspace-cli
105136
```
106137

107-
## End to end testing of the rest api (runs in travis).
108-
_In this instance, only the REST api runs in Docker using the Entities dataset. Travis will perform CI testing of Angular using Node to drive the tests._
138+
## End to end testing of the REST API (runs in GitHub Actions CI).
139+
_In this instance, only the REST api runs in Docker using the Entities dataset. GitHub Actions will perform CI testing of Angular using Node to drive the tests. See `.github/workflows/build.yml` for more details._
109140

141+
This command is only really useful for testing our Continuous Integration process.
110142
```
111-
docker-compose -p d7ci -f docker/docker-compose-travis.yml up -d
143+
docker-compose -p d7ci -f docker/docker-compose-ci.yml up -d
112144
```

docker/docker-compose-dist.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ services:
1919
DSPACE_UI_HOST: dspace-angular
2020
DSPACE_UI_PORT: '4000'
2121
DSPACE_UI_NAMESPACE: /
22+
# NOTE: When running the UI in production mode (which the -dist image does),
23+
# these DSPACE_REST_* variables MUST point at a public, HTTPS URL.
24+
# This is because Server Side Rendering (SSR) currently requires a public URL,
25+
# see this bug: https://github.com/DSpace/dspace-angular/issues/1485
2226
DSPACE_REST_SSL: 'true'
2327
DSPACE_REST_HOST: api7.dspace.org
2428
DSPACE_REST_PORT: 443

docker/docker-compose-rest.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
# proxies.trusted.ipranges: This setting is required for a REST API running in Docker to trust requests
4040
# from the host machine. This IP range MUST correspond to the 'dspacenet' subnet defined above.
4141
proxies__P__trusted__P__ipranges: '172.23.0'
42-
image: dspace/dspace:dspace-7_x-test
42+
image: "${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-dspace-7_x-test}"
4343
depends_on:
4444
- dspacedb
4545
networks:
@@ -82,8 +82,7 @@ services:
8282
# DSpace Solr container
8383
dspacesolr:
8484
container_name: dspacesolr
85-
# Uses official Solr image at https://hub.docker.com/_/solr/
86-
image: solr:8.11-slim
85+
image: "${DOCKER_OWNER:-dspace}/dspace-solr:${DSPACE_VER:-dspace-7_x}"
8786
# Needs main 'dspace' container to start first to guarantee access to solr_configs
8887
depends_on:
8988
- dspace
@@ -96,28 +95,26 @@ services:
9695
tty: true
9796
working_dir: /var/solr/data
9897
volumes:
99-
# Mount our "solr_configs" volume available under the Solr's configsets folder (in a 'dspace' subfolder)
100-
# This copies the Solr configs from main 'dspace' container into 'dspacesolr' via that volume
101-
- solr_configs:/opt/solr/server/solr/configsets/dspace
10298
# Keep Solr data directory between reboots
10399
- solr_data:/var/solr/data
104100
# Initialize all DSpace Solr cores using the mounted local configsets (see above), then start Solr
105101
# * First, run precreate-core to create the core (if it doesn't yet exist). If exists already, this is a no-op
106-
# * Second, copy updated configs from mounted configsets to this core. If it already existed, this updates core
107-
# to the latest configs. If it's a newly created core, this is a no-op.
102+
# * Second, copy configsets to this core:
103+
# Updates to Solr configs require the container to be rebuilt/restarted:
104+
# `docker-compose -p d7 -f docker/docker-compose.yml -f docker/docker-compose-rest.yml up -d --build dspacesolr`
108105
entrypoint:
109106
- /bin/bash
110107
- '-c'
111108
- |
112109
init-var-solr
113110
precreate-core authority /opt/solr/server/solr/configsets/dspace/authority
114-
cp -r -u /opt/solr/server/solr/configsets/dspace/authority/* authority
111+
cp -r /opt/solr/server/solr/configsets/dspace/authority/* authority
115112
precreate-core oai /opt/solr/server/solr/configsets/dspace/oai
116-
cp -r -u /opt/solr/server/solr/configsets/dspace/oai/* oai
113+
cp -r /opt/solr/server/solr/configsets/dspace/oai/* oai
117114
precreate-core search /opt/solr/server/solr/configsets/dspace/search
118-
cp -r -u /opt/solr/server/solr/configsets/dspace/search/* search
115+
cp -r /opt/solr/server/solr/configsets/dspace/search/* search
119116
precreate-core statistics /opt/solr/server/solr/configsets/dspace/statistics
120-
cp -r -u /opt/solr/server/solr/configsets/dspace/statistics/* statistics
117+
cp -r /opt/solr/server/solr/configsets/dspace/statistics/* statistics
121118
exec solr -f
122119
volumes:
123120
assetstore:

0 commit comments

Comments
 (0)