Skip to content

Commit ca5bffb

Browse files
authored
Merge pull request #1391 from solid/dev
Merge dev branch?
2 parents dcc5f90 + 61c6868 commit ca5bffb

28 files changed

+819
-481
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818

1919
# Additional .npmignore entries (not in .gitignore)
2020
/test
21+
/docker-image

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v8.16.0
1+
v13.2.0

README.md

+28-19
Original file line numberDiff line numberDiff line change
@@ -229,26 +229,35 @@ docker run -p 8443:8443 --name solid nodesolidserver/node-solid-server
229229

230230
This will enable you to login to solid on https://localhost:8443 and then create a new account
231231
but not yet use that account. After a new account is made you will need to create an entry for
232-
it in your local (/etc/)hosts file in line with the account and subdomain i.e.
233-
232+
it in your local (/etc/)hosts file in line with the account and subdomain, i.e. --
233+
```pre
234234
127.0.0.1 newsoliduser.localhost
235-
235+
```
236236
Then you'll be able to use solid as intended.
237237

238238
You can modify the config within the docker container as follows:
239239

240-
- Copy the config to the current directory with: `docker cp solid:/usr/src/app/config.json .`
240+
- Copy the config to the current directory with:
241+
```
242+
docker cp solid:/usr/src/app/config.json .
243+
```
241244
- Edit the `config.json` file
242-
- Copy the file back with `docker cp config.json solid:/usr/src/app/`
243-
- Restart the server with `docker restart solid`
245+
- Copy the file back with
246+
```
247+
docker cp config.json solid:/usr/src/app/
248+
```
249+
- Restart the server with
250+
```
251+
docker restart solid
252+
```
244253

245254
If you want to help improve the Docker image, then you can build it locally with:
246255
```bash
247256
git clone https://github.com/solid/node-solid-server
248257
cd node-solid-server
249258
docker build .
250259
```
251-
We have automatic builds set up so commits to master will trigger a build of https://hub.docker.com/r/nodesolidserver/node-solid-server.
260+
We have automatic builds set up, so commits to master will trigger a build of https://hub.docker.com/r/nodesolidserver/node-solid-server.
252261

253262
## Library Usage
254263

@@ -272,18 +281,18 @@ default settings.
272281

273282
```javascript
274283
{
275-
cache: 0, // Set cache time (in seconds), 0 for no cache
276-
live: true, // Enable live support through WebSockets
277-
root: './', // Root location on the filesystem to serve resources
278-
secret: 'node-ldp', // Express Session secret key
279-
cert: false, // Path to the ssl cert
280-
key: false, // Path to the ssl key
281-
mount: '/', // Where to mount Linked Data Platform
282-
webid: false, // Enable WebID+TLS authentication
283-
suffixAcl: '.acl', // Suffix for acl files
284-
corsProxy: false, // Where to mount the CORS proxy
285-
errorHandler: false, // function(err, req, res, next) to have a custom error handler
286-
errorPages: false // specify a path where the error pages are
284+
cache: 0, // Set cache time (in seconds), 0 for no cache
285+
live: true, // Enable live support through WebSockets
286+
root: './', // Root location on the filesystem to serve resources
287+
secret: 'node-ldp', // Express Session secret key
288+
cert: false, // Path to the ssl cert
289+
key: false, // Path to the ssl key
290+
mount: '/', // Where to mount Linked Data Platform
291+
webid: false, // Enable WebID+TLS authentication
292+
suffixAcl: '.acl', // Suffix for acl files
293+
corsProxy: false, // Where to mount the CORS proxy
294+
errorHandler: false, // function(err, req, res, next) to have a custom error handler
295+
errorPages: false // specify a path where the error pages are
287296
}
288297
```
289298

docker-image/.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test/
2+
.pytest_cache/
3+
.idea

docker-image/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pytest_cache/
2+
__pycache__
3+
data/

docker-image/CONTRIBUTING.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# How to contribute
2+
3+
If you want to experiment with the image and/or contribute to its development,
4+
please read this document.
5+
6+
## Run tests
7+
8+
```bash
9+
make test
10+
```
11+
12+
The first run might take a while, since the image has to be build. Follow up test runs will be faster.
13+
14+
## Start & stop locally
15+
16+
Build and run a local container named solid-server via
17+
18+
```bash
19+
make start
20+
```
21+
22+
and stop it via
23+
24+
```bash
25+
make stop
26+
```
27+
28+
## Inspect & debug
29+
30+
To start a shell in a running container (started with `make start`) run `make attach`.
31+
32+
To just run a shell in the built image (without starting solid) run `make inspect`.
33+

docker-image/Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
test: ## run testinfra tests against the project
2+
docker run --rm -t \
3+
-v $(shell pwd):/project \
4+
-v /var/run/docker.sock:/var/run/docker.sock:ro \
5+
aveltens/docker-testinfra
6+
7+
lint: ## run hadolint against the Dockerfile
8+
docker run --rm -i hadolint/hadolint < src/Dockerfile
9+
10+
build: ## build the docker image
11+
cd src && docker build --tag nodesolidserver/node-solid-server .
12+
13+
inspect: build ## run a shell in the docker image
14+
docker run --rm -it --entrypoint sh nodesolidserver/node-solid-server
15+
16+
start: build ## start solid-server docker container
17+
docker run --rm \
18+
-it -d \
19+
-p 8443:8443 \
20+
-u "$(id -u):$(id -g)" \
21+
-v $(shell pwd)/data:/opt/solid/data \
22+
--name solid-server \
23+
nodesolidserver/node-solid-server
24+
25+
stop: ## stop the solid-server docker container
26+
docker stop solid-server
27+
28+
attach: ## execute a shell in the running solid-server docker container
29+
docker exec -it solid-server sh
30+
31+
.PHONY: test build inspect run attach

docker-image/README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# NSS Docker image
2+
3+
Containerized version of node-solid-server
4+
5+
## How to use
6+
7+
For quickly trying out this image or solid-server in general you can run:
8+
```bash
9+
docker run -p 8443:8443 nodesolidserver/node-solid-server
10+
```
11+
12+
You will be able to access the server via `https://localhost:8443` then. It will use auto-generated self-signed certificates and is **not suited for production use**. For a production server you will have to create some real certificates and configure environment variables, like SOLID_SERVER_URI, SOLID_SSL_KEY and SOLID_SSL_CERT. Take a look at the examples folder [at GitHub](https://github.com/angelo-v/docker-solid-server/tree/master/examples) for details.
13+
14+
### Environment variables
15+
16+
All solid configuration flags can be set by an equivalent environment variable.
17+
The official solid-server documentation
18+
[explains them in detail](https://github.com/solid/node-solid-server#extra-flags-expert).
19+
20+
### Docker compose
21+
22+
For a productive setup you may want to use docker-compose. Example setups can be found
23+
in the [examples folder](https://github.com/angelo-v/docker-solid-server/tree/master/examples). Here is an overview of what is in there:
24+
25+
#### Simple setup without proxy
26+
27+
`./examples/docker-compose.simple.yml`
28+
29+
Run solid-server directly on HTTPS port 443 without a proxy in between.
30+
You will need to have your certificates ready and mount them into the container.
31+
32+
#### Running solid behind nginx proxy
33+
34+
`./examples/docker-compose.nginx.yml`
35+
36+
Run solid-server on port 8443 behind a nginx proxy on 443. You will need to setup an nginx container with letsencrypt companion [as described here](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion).
37+
38+
#### Other setups
39+
40+
The setup you need is not presented here? Feel free to ask, or provide a Pull Request
41+
with your solution.
42+
43+
## Feedback & Discussion
44+
45+
There is a [topic in the Solid Forum](https://forum.solidproject.org/t/official-solid-docker-image/748/5),
46+
you are welcome to join in.
47+
48+
## Contributing
49+
50+
If you would like to contribute to the development of this image,
51+
see [CONTRIBUTING.md](./CONTRIBUTING.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This example assumes, that you are running a jwilders/nginx proxy
2+
# with certificate generation by a letsencrypt companion container
3+
# as described here:
4+
#
5+
# https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion/blob/master/docs/Docker-Compose.md
6+
#
7+
# This should provide a docker volume containing the generated certificates.
8+
# We will use the same cert and key as the webproxy for the actual solid server. While it seems to
9+
# work, I am not sure if it is actually a good idea. Please file an issue if you want to discuss this.
10+
11+
# Adjust any line that is commented with (!):
12+
# 1. Change any occurrence of the domain `solid.example` to your actual domain
13+
# 2. Adjust the `latest` tag to a specific version you want to use.
14+
15+
version: '3.7'
16+
services:
17+
server:
18+
image: nodesolidserver/node-solid-server:latest # (!) use specific version tag here
19+
20+
# this ensures automatic container start, when host reboots
21+
restart: always
22+
23+
expose:
24+
- 8443
25+
26+
volumes:
27+
# mount local directories to the container
28+
# (!) the host directories have to exist and be owned by UID 1000
29+
- /opt/solid/data:/opt/solid/data
30+
- /opt/solid/.db:/opt/solid/.db
31+
- /opt/solid/config:/opt/solid/config
32+
- nginxproxy_certs:/opt/solid/certs
33+
34+
environment:
35+
# (!) use your actual SOLID_SERVER_URI
36+
- "SOLID_SERVER_URI=https://solid.example"
37+
# (!) adjust path to the letsencrypt key and cert
38+
- "SOLID_SSL_KEY=/opt/solid/certs/solid.example/key.pem"
39+
- "SOLID_SSL_CERT=/opt/solid/certs/solid.example/fullchain.pem"
40+
# (!) use your actual host name
41+
- "VIRTUAL_HOST=solid.example"
42+
- "VIRTUAL_PORT=8443"
43+
- "VIRTUAL_PROTO=https"
44+
# (!) use your actual host name
45+
- "LETSENCRYPT_HOST=solid.example"
46+
47+
volumes:
48+
# (!) mount certificates from an external volume from your nginx setup
49+
nginxproxy_certs:
50+
external: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file is an example for running solid server directly on port 443 with
2+
# existing (letsencrypt) certificates and without reverse proxy.
3+
4+
# To use it adjust any line that is commented with (!):
5+
# 1. Change any occurrence of the domain `solid.example` to your actual domain
6+
# 2. Adjust the `latest` tag to a specific version you want to use.
7+
8+
version: '3.7'
9+
services:
10+
server:
11+
image: nodesolidserver/node-solid-server:latest # (!) use specific version tag here
12+
13+
# this ensures automatic container start, when host reboots
14+
restart: always
15+
16+
ports:
17+
- 443:8443
18+
19+
volumes:
20+
# mount local directories to the container
21+
# (!) the host directories have to exist and be owned by UID 1000
22+
- /opt/solid/data:/opt/solid/data
23+
- /opt/solid/.db:/opt/solid/.db
24+
- /opt/solid/config:/opt/solid/config
25+
26+
# (!) mount existing TLS certificates, e.g. from letsencrypt
27+
# (!) ensure that the key and fullchain files are readable by UID 1000
28+
- /etc/letsencrypt/live/solid.example/:/opt/solid/certs
29+
30+
environment:
31+
# (!) use your actual SOLID_SERVER_URI
32+
- "SOLID_SERVER_URI=https://solid.example"
33+
- "SOLID_SSL_KEY=/opt/solid/certs/key.pem"
34+
- "SOLID_SSL_CERT=/opt/solid/certs/fullchain.pem"

docker-image/src/Dockerfile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM node:10-alpine
2+
3+
RUN apk add --no-cache openssl
4+
5+
ARG SOLID_SERVER_VERSION=latest
6+
RUN npm install -g solid-server@${SOLID_SERVER_VERSION}
7+
8+
# image configuration
9+
ENV SOLID_HOME=/opt/solid
10+
ENV PROCESS_USER=node
11+
ENV TEMPORARY_CERT_NAME=solid-temporary
12+
13+
WORKDIR ${SOLID_HOME}
14+
COPY ./entrypoint.sh ./entrypoint.sh
15+
COPY ./checks.sh ./checks.sh
16+
COPY ./create-temporary-cert.sh ./create-temporary-cert.sh
17+
RUN chown --recursive ${PROCESS_USER}:${PROCESS_USER} ${SOLID_HOME}
18+
19+
USER ${PROCESS_USER}
20+
21+
# solid configuration
22+
ENV SOLID_ROOT=${SOLID_HOME}/data
23+
ENV SOLID_SSL_KEY=${SOLID_HOME}/${TEMPORARY_CERT_NAME}.key
24+
ENV SOLID_SSL_CERT=${SOLID_HOME}/${TEMPORARY_CERT_NAME}.crt
25+
ENV SOLID_PORT=8443
26+
ENV SOLID_CORS_PROXY=/xss
27+
ENV DEBUG=solid:*
28+
29+
VOLUME $SOLID_HOME
30+
31+
ENTRYPOINT ["./entrypoint.sh"]
32+
33+
CMD ["start"]

docker-image/src/checks.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
3+
echo "checking preconditions..."
4+
5+
checks_failed=0
6+
7+
check_failed()
8+
{
9+
checks_failed=$((checks_failed + 1))
10+
}
11+
check_if_writable()
12+
{
13+
# checks if the given dir is writable, if it exists
14+
# it's ok if the dir does not exist at all, because it will be created
15+
# during solid server startup then and have the correct permissions
16+
dir=$1
17+
if [ -d "${dir}" ]; then
18+
if [ -w "${dir}" ]; then
19+
echo "${dir} is accessible by $(whoami)"
20+
else
21+
echo "${dir} not writable by $(whoami)"
22+
check_failed
23+
fi
24+
fi
25+
}
26+
27+
check_if_file_readable()
28+
{
29+
# checks if the given file exists and is readable
30+
file=$1
31+
if [ -e "${file}" ]; then
32+
if [ -r "${file}" ]; then
33+
echo "${file} is accessible by $(whoami)"
34+
else
35+
echo "${file} not readable by $(whoami)"
36+
check_failed
37+
fi
38+
else
39+
echo "${file} does not exist"
40+
check_failed
41+
fi
42+
}
43+
44+
check_if_writable "${SOLID_HOME}/config"
45+
check_if_writable "${SOLID_HOME}/data"
46+
check_if_writable "${SOLID_HOME}/.db"
47+
check_if_file_readable "${SOLID_SSL_KEY}"
48+
check_if_file_readable "${SOLID_SSL_CERT}"
49+
50+
if [ "$checks_failed" -gt 0 ]; then
51+
echo "Finished: ERROR"
52+
exit 1
53+
else
54+
echo "Finished: SUCCESS"
55+
exit 0;
56+
fi

0 commit comments

Comments
 (0)