Skip to content

Commit

Permalink
update docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Jul 1, 2024
1 parent f7745f3 commit 98104df
Show file tree
Hide file tree
Showing 35 changed files with 172 additions and 1,113 deletions.
69 changes: 0 additions & 69 deletions DEVSETUP.md

This file was deleted.

101 changes: 33 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Superdesk
[![Build Status](https://travis-ci.org/superdesk/superdesk.png?branch=master)](https://travis-ci.org/superdesk/superdesk)
[![Code Health](https://landscape.io/github/superdesk/superdesk/master/landscape.svg?style=flat)](https://landscape.io/github/superdesk/superdesk/master)
[![Coverage Status](https://coveralls.io/repos/superdesk/superdesk/badge.svg)](https://coveralls.io/r/superdesk/superdesk)
[![Code Climate](https://codeclimate.com/github/superdesk/superdesk/badges/gpa.svg)](https://codeclimate.com/github/superdesk/superdesk)
[![Requirements Status](https://requires.io/github/superdesk/superdesk/requirements.svg?branch=master)](https://requires.io/github/superdesk/superdesk/requirements/?branch=master)
[![CI](https://github.com/superdesk/superdesk-stt/actions/workflows/tests.yml/badge.svg)](https://github.com/superdesk/superdesk-stt/actions/workflows/tests.yml)

Superdesk is an open source end-to-end news creation, production, curation,
distribution and publishing platform developed and maintained by Sourcefabric
with the sole purpose of making the best possible software for journalism. It
is scaleable to suit news organizations of any size. See the [Superdesk website] (http://www.superdesk.org) for more information.
is scaleable to suit news organizations of any size. See the [Superdesk website] (https://www.superdesk.org) for more information.

Looking to stay up to date on the latest news? [Subscribe] (http://eepurl.com/bClQlD) to our monthly newsletter.

Expand All @@ -26,78 +22,47 @@ Find more information about the client configuration in the README file of the r
1. Clone the repository
2. Navigate to the folder where you've cloned this repository (if it's the main repo, go inside the `client` folder).
3. Run `npm install` to install dependencies.
4. Run `grunt server` to run the web server.
4. Run `npm run build` to build the app.
4. Run `npm run start` to run the web server.
5. Open browser and navigate to `localhost:9000`.

The `grunt server` attempts to resolve the API and websockets server to a local instance. In order to use a different instance, you may add the arguments `--server=<host:[port]>` and `--ws=<host:[port]>` to the command.

### Server

#### Dependencies (for non-Docker installations)
#### Dependencies

* Python & Pyvenv 3+
* MongoDB
* ElasticSearch <= 1.7.x
* Python 3.8-3.10
* MongoDB 4-6
* ElasticSearch 7.x
* Redis

#### MacOS

For the sake of this walkthrough, it is considered that your python binary is called `python3`. Please amend as needed for your own system.

1. Install dependencies using `brew` (make sure you do a `brew update` first): `python3`, `mongodb`, `elasticsearch`, `redis`.
2. Create a virtual envirnoment in a folder of your choice, for example `mkdir ~/pyvenv && pyvenv-3.5 ~/pyvenv`.
3. Activate the environment by running its activation script: `. ~/pyvenv/bin/activate`. All of the following steps need to run under the virtual environment.
4. Install _pip_ dependencies by running (inside repository root): `pip install -r server/requirements.txt`.
5. Start all dependent services: `mongod`, `redis-server`, `elasticsearch`.
6. For an initially empty database, you may initialize and pre-populate it by running (inside the `server` folder): `python3 manage.py app:initialize_data && python3 manage.py app:prepopulate`.
7. Finally, start the server (inside the `server` folder) using `honcho start`.
#### Ubuntu 22.04

# install system wide packages
$ RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-dev python3-pip python3-venv git gcc curl \
libxml2-dev libxslt-dev \
pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl \
libjpeg-dev zlib1g-dev libmagic-dev

# in server folder install dependencies
$ python3 -m venv env
$ . env/bin/activate
$ python3 -m pip install -U pip wheel setuptools
$ python3 -m pip install -Ur requirements.txt

# init the app
$ honcho run python manage.py app:initialize_data

# create admin user
$ honcho run users:create -u admin -p admin -e admin@localhost --admin

# run the app
$ honcho start

#### Linux (with Docker)

Use [docker-compose](http://docs.docker.com/compose/ "") and the config from the `docker` folder or build docker images manually from `Dockerfile`s from `client` and `server` folders accordingly.

###### install system-wide dependencies

```sh
$ sudo apt-get install python-virtualenv git
```
and install [the newest docker](https://docs.docker.com/installation/).
and make sure you can run [docker without sudo](http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo).


###### install docker compose and run app

```sh
$ git clone https://github.com/superdesk/superdesk.git
$ cd superdesk
$ git clone https://github.com/superdesk/superdesk-content-api.git
$ ./scripts/docker-local-demo.sh
```

Open in a browser `http://localhost:8080` after the server will be ready.

If you can't log in then you probably need to run `./scripts/docker-local-create-user.sh`. The default username is `admin` and the password is `admin`.

If you're going to assign some hostname to the instance, you should also set it in the config file [docker-compose-prebuilt.yml](./docker/docker-compose-prebuilt.yml) instead of `localhost`.

For manual installation just follow the steps described in the [Dockerfile](./Dockerfile).

###Contribute

In general, contributing code to the Superdesk project – whether it is a new feature or a bug fix – is simple and follows this general path:

1) Get a copy of the project source code or [setup a dev environment with docker](DEVSETUP.md)
<P>2) Work on the code changes</P>
<P>3) Submit a Pull Request whenever you are ready</P>

###Questions and issues

Our [issue tracker] (https://dev.sourcefabric.org/projects/SD) is only for bug reports and feature requests. Anything else, such as questions or general feedback, should be posted in the [forum] (https://forum.sourcefabric.org/categories/superdesk-dev).

###A special thanks to...

Users, developers and development partners that have contributed to the Superdesk project. Also, to all the other amazing open-source projects that make Superdesk possible!

###License
Use Docker Compose

Superdesk is available under the [AGPL version 3] (https://www.gnu.org/licenses/agpl-3.0.html) open source license.
$ docker compose up
3 changes: 3 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/dist
data
11 changes: 11 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:14

WORKDIR /opt/client

COPY package.json .
COPY package-lock.json .
RUN npm ci

COPY . .
RUN npm run build
CMD ["npm", "run", "start"]
4 changes: 1 addition & 3 deletions docker/nginx.conf → client/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,4 @@ http {

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

daemon off;
}
14 changes: 9 additions & 5 deletions docker/start.sh → client/docker/start.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/bash
cd /opt/superdesk/client/dist &&
set -e

cd /opt/superdesk/client/dist

# replace default client config with env vars
sed -i \
-e "s/http:\/\/localhost:5000\/api/$(echo $SUPERDESK_URL | sed 's/\//\\\//g')/g" \
-e "s/ws:\/\/localhost:5100/$(echo $SUPERDESK_WS_URL | sed 's/\//\\\//g')/g" \
-e "s/ws:\/\/0.0.0.0:5100/$(echo $SUPERDESK_WS_URL | sed 's/\//\\\//g')/g" \
-e 's/iframely:{key:""}/iframely:{key:"'$IFRAMELY_KEY'"}/g' \
app*.js &&
nginx &
app*.js

which nginx

cd /opt/superdesk &&
bash ./scripts/fig_wrapper.sh honcho start
exec "$@"
22 changes: 11 additions & 11 deletions docker/superdesk_vhost.conf → client/docker/superdesk_vhost.conf
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
upstream superdesk_docker {
server localhost:5000;
upstream superdesk_api {
server superdesk-server:5000;
}

upstream superdesk_ws_docker {
server localhost:5100;
upstream superdesk_ws {
server superdesk-server:5100;
}

upstream superdesk_pubapi_docker {
server pubapi:5050;
upstream superdesk_capi {
server superdesk-server:5400;
}

server {
server_name "";

location /ws {
proxy_pass http://superdesk_ws_docker;
proxy_pass http://superdesk_ws;
proxy_http_version 1.1;
proxy_buffering off;
proxy_read_timeout 3600;
Expand All @@ -23,17 +23,17 @@ server {
proxy_set_header Host $host;
}

location /api {
proxy_pass http://superdesk_docker;
location /capi {
proxy_pass http://superdesk_capi;
proxy_redirect off;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /pubapi {
proxy_pass http://superdesk_pubapi_docker;
location /api {
proxy_pass http://superdesk_api;
proxy_redirect off;

proxy_set_header Host $http_host;
Expand Down
50 changes: 41 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ version: "3.2"
services:

mongodb:
image: mongo:4
image: mongo:6
networks:
- superdesk
expose:
- "27017"
ports:
- "27017:27017"

redis:
image: redis:3
image: redis:alpine
networks:
- superdesk
expose:
- "6379"
ports:
- "6379:6379"

Expand All @@ -25,12 +21,48 @@ services:
- discovery.type=single-node
networks:
- superdesk
expose:
- "9200"
- "9300"
ports:
- "9200:9200"

server:
build: ./server
depends_on:
- redis
- mongodb
- elastic
environment:
- WEB_CONCURRENCY=2
- MONGO_URI=mongodb://mongodb/superdesk
- CONTENTAPI_MONGO_URI=mongodb://mongodb/superdesk_capi
- PUBLICAPI_MONGO_URI=mongodb://mongodb/superdesk_papi
- LEGAL_ARCHIVE_URI=mongodb://mongodb/superdesk_legal
- ARCHIVED_URI=mongodb://mongodb/superdesk_archive
- ELASTICSEARCH_URL=http://elastic:9200
- ELASTICSEARCH_INDEX=superdesk
- CELERY_BROKER_URL=redis://redis:6379/1
- REDIS_URL=redis://redis:6379/1
- DEFAULT_TIMEZONE=Europe/Prague
- SECRET_KEY=*k^&9)byk=8en9n1sg7-xj4f8wr2mh^x#t%_2=1=z@69oxt50!
# More configuration options can be found at https://superdesk.readthedocs.io/en/latest/settings.html
networks:
- superdesk
ports:
- "5000:5000"
develop:
watch:
- action: sync+restart
path: ./server
ignore:
- env/
- requirements.txt

client:
build: ./client
ports:
- "9000:9000"
networks:
- superdesk

networks:
superdesk:
driver: bridge
1 change: 0 additions & 1 deletion docker/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions docker/Procfile-dev

This file was deleted.

2 changes: 0 additions & 2 deletions docker/README.md

This file was deleted.

Loading

0 comments on commit 98104df

Please sign in to comment.