Skip to content

Commit

Permalink
Setup installation instruction for portal + containerization
Browse files Browse the repository at this point in the history
  • Loading branch information
AbcSxyZ committed May 7, 2024
1 parent 39b40e7 commit 394b31b
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 5 deletions.
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM nginx:latest

# Configuration variable for HTTPS (through Let's Encrypt)
ARG HTTPS=false
ENV DOMAIN=organisation.org
ENV [email protected]

# Use of HTTP & HTTPS ports
EXPOSE 80
EXPOSE 443

# Install dependencies
RUN apt-get update && \
apt-get install -y wget git

# Install Quarto
ARG QUARTO_VERSION=1.4.554
RUN wget https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.deb && \
apt install -y ./quarto-$QUARTO_VERSION-linux-amd64.deb && \
rm quarto-$QUARTO_VERSION-linux-amd64.deb

# Dependencies to enable HTTPS with Let's Encrypt
RUN if [ "$HTTPS" = "true" ]; then \
apt-get update && \
apt-get install -y certbot; \
fi

# Use of local sources of the repository to launch the portal
COPY . /usr/share/portal
WORKDIR /usr/share/portal

RUN quarto render --output-dir html && \
# Fix of README not used as index by quarto \
cd html && ln -sf README.html index.html

ENTRYPOINT ["/usr/share/portal/entrypoint.sh"]
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ A gateway to knowledge in the digital world.

Retrieve the list of [available tools](toolbox/README.md) to work with open models.

## Education
Visit the [knowledge base on open models](https://open-models.org) to learn more about these dynamics.

Learn more about how open models work and how to get the most out of them with the [open models knowledge
base](https://open-models.org).
## Portal Installation

A portal can be deployed to create your own database of open resources. Follow the [installation instructions](installation.md)
to set up a portal.

## Community

The portal is managed collaboratively on [GitHub](https://github.com/Open-Models/Portal), see [contribution guidelines](contribute.md)
if you want to provide support to build the portal and tools.
Open Portal is managed collaboratively on [GitHub](https://github.com/Open-Models/Portal), see [contribution guidelines](contribute.md)
if you want to provide support to build it.

You may find support for your open activities in the github environment, it could be useful to interact directly with
the communities around the tools.
Expand Down
25 changes: 25 additions & 0 deletions config/open-portal-ssl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80;
server_name ${DOMAIN};

location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name ${DOMAIN};

# SSL certificate configuration
ssl_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${DOMAIN}/privkey.pem;

# Other SSL configuration directives can go here

# Serve HTTPS content
location / {
root /usr/share/portal/html;
}
}

7 changes: 7 additions & 0 deletions config/open-portal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server {
server_name ${DOMAIN};

location / {
root /usr/share/portal/html;
}
}
17 changes: 17 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

CONFIG_FILE=open-portal.conf
CONFIG_FOLDER=/usr/share/portal/config

# Create let's encrypt certificate
if [ "$(command -v certbot)" ]
then
CONFIG_FILE=open-portal-ssl.conf
# Use --test-cert to avoid real certificate
certbot certonly --standalone --test-cert -d $DOMAIN -m $MAIL --agree-tos -n
fi

# Set up configuration file
envsubst '${DOMAIN}' < $CONFIG_FOLDER/$CONFIG_FILE > /etc/nginx/conf.d/default.conf

nginx -g "daemon off;"
66 changes: 66 additions & 0 deletions installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Portal Installation

You can build your own open portal to bring together the open resources you use or want to provide. This guide will help
you set up a portal locally or for a website.

## Dependencies

The website is rendered by Quarto, first follow their [installation instructions](https://quarto.org/docs/get-started/) for your device.

**Using Linux (Debian)**:
```bash
# Basic apt dependencies
sudo apt update
sudo apt install git

# Install Quarto
VERSION=1.4.554

wget https://github.com/quarto-dev/quarto-cli/releases/download/v$VERSION/quarto-$VERSION-linux-amd64.deb
sudo apt install ./quarto-$VERSION-linux-amd64.deb
```

## Local Portal

Use the following steps to download and start the portal locally.

```bash
# Download portal repository
git clone https://github.com/Open-Models/Open-Portal.git

# Go into the repository folder
cd Open-Portal

# Render html website (generated in the _site folder)
quarto render
```

The portal can be then published with any web server. The command `quarto preview` can be used to display the website locally.

> **Warning**: Quarto do not use `README.md` files by default as `index.html` (see
> [quarto-dev/quarto-cli#1615](https://github.com/quarto-dev/quarto-cli/issues/1615),
> for now you can fix the home page with the following command: `rm index.html && ln -s README.html index.html`
## Using Docker

The portal can be installed using docker containers. If needed, see installation instructions from [Docker
website](https://docs.docker.com/engine/install/).

**Steps to launch the portal:**
```bash
git clone https://github.com/Open-Models/Open-Portal
cd Open-Portal

sudo docker build -t portal-image .
sudo docker run --name portal -p 80:80 portal-image
```

The portal is created using sources of the local repository.

**To initiate a portal served under https:**
```bash
sudo docker build --build-arg HTTPS=true -t portal-image .
sudo docker run -e DOMAIN=portal.organisation.org -e [email protected] -p 80:80 -p 443:443 portal-image
```

`HTTPS`, `DOMAIN` & `MAIL` variables are required to obtain an SSL certificate using let's encrypt.

0 comments on commit 394b31b

Please sign in to comment.