Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR-23781] Migrate docs to Jenkins #358

Merged
merged 30 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
506bae7
added venv didrectories to exclusions
en-ver Jan 22, 2025
d003f91
refactoring
en-ver Jan 22, 2025
418cb1a
creanup from the ruby way of deployment
en-ver Jan 23, 2025
c5dafe3
move robots.txt to nginx level
en-ver Jan 24, 2025
a373777
dockerized deployment introduction
en-ver Jan 24, 2025
bef9cb4
Merge branch vo-PR-23724 into enver-PR-23781-migrate-docs-to-jenkins
ilovepinkpony1 Jan 24, 2025
ad0d42a
refactoring + documentation completion
en-ver Jan 25, 2025
eb557d0
doc refactoring
en-ver Jan 25, 2025
0dda506
docs reformat
en-ver Jan 25, 2025
c2624ea
Update README-devops.md
en-ver Jan 26, 2025
809d99b
rename `staging-bastion` to `staging`
en-ver Jan 26, 2025
5a9074b
get back PULL_REQUEST_TEMPLATE.md
en-ver Jan 26, 2025
05bf23b
replace bastion-docs.talkable.com with staging-docs.talkable.com
en-ver Jan 26, 2025
c0192d8
change nginx:1.27 to nginx:1.27.3
en-ver Jan 26, 2025
0244c2d
hardcode the dependencies versions, rename confusing requirements-dev…
en-ver Jan 26, 2025
d9167bb
replace deprecated docker-compose with modern "docker compose"
en-ver Jan 26, 2025
100b25b
gitignore refactoring
en-ver Jan 27, 2025
24f8920
Maintenance guide intro
en-ver Jan 27, 2025
c205648
build option added to make sure if it builds up to date image
en-ver Jan 27, 2025
05d0c4a
Update README.md
en-ver Jan 27, 2025
c7f5d7b
nginx: add caching policy and compression
en-ver Jan 27, 2025
f215c9e
Add newline at end of files
zhuravel Jan 27, 2025
83ea286
different modes of Sphinx builder for different environments
en-ver Jan 27, 2025
2430bb7
get the circleci back
en-ver Jan 27, 2025
29aef03
change the html mode to dirhtml for cicleci run
en-ver Jan 27, 2025
d70976d
ENVIRONMENT variable intro to circleci - conditional. and let the job…
en-ver Jan 27, 2025
71dfa55
remove filter and add fallback env variable value
en-ver Jan 27, 2025
f6478ab
circleci env variable processing improvement
en-ver Jan 27, 2025
2b70a61
Cleanup
zhuravel Jan 27, 2025
fa42906
Merge branch 'vo-PR-23724' into enver-PR-23781-migrate-docs-to-jenkins
en-ver Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ executors:
- auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_ACCESS_TOKEN
image: cimg/python:3.12
image: cimg/python:3.13
environment:
ENVIRONMENT: production

orbs:
python: circleci/python@2.1.1
python: circleci/python@3.0.0

jobs:
build:
Expand All @@ -18,21 +20,15 @@ jobs:
steps:
- checkout

- python/install-packages:
app-dir: ~/project
- python/install-packages

- run:
name: Build documentation
command: sphinx-build -nW -b html -d build/doctrees source build/html
command: sphinx-build -nW -b dirhtml -d build/doctrees source build/html

workflows:
workflow:
jobs:
- build:
context:
- org-global
filters:
branches:
ignore:
- gh-pages
- /.*-gh-pages/
10 changes: 10 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The port to use to populate the documentation on your local machine or server
LOCAL_PORT=8080

# Possible values: development, staging, production
ENVIRONMENT=development

# Base urls used for the canonical urls compilation
DEVELOPMENT_HOST=localhost
STAGING_HOST=staging-docs.talkable.com
PRODUCTION_HOST=docs.talkable.com
4 changes: 0 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<!--- Provide a general summary of your changes in the Title above -->

## Demo
<!--- Please provide a link to a demo -->
https://deploy-preview-{{id}}--talkable-docs.netlify.app/

## Related Stories
<!--- If this pull request is related to JIRA story, please link to the story here -->
[![](http://proxies.talkable.com/talkable/PR-1234)](https://talkable.atlassian.net/browse/PR-1234)
20 changes: 16 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# IDE
.idea
.vscode

# Local
*.log
.env

# Sphinx
_build

# Python
.venv
__pycache__

# Ruby
/build
/.bundle
Gemfile.lock
source/_static/test
.pivotalrc
.idea
*.log
1 change: 0 additions & 1 deletion .ruby-gemset

This file was deleted.

1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

1 change: 0 additions & 1 deletion CNAME

This file was deleted.

14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.13-alpine3.21

# Install dependencies
WORKDIR /docs
ADD requirements.txt /docs
RUN python3 -m pip install -r requirements.txt

CMD if [ "$ENVIRONMENT" = "development" ]; then \
echo "Running Sphinx in Development mode"; \
sphinx-autobuild -b dirhtml /docs/source /docs/_build; \
else \
echo "Running Sphinx in Staging/Production mode"; \
sphinx-build -b dirhtml /docs/source /docs/_build; \
fi
11 changes: 0 additions & 11 deletions Gemfile

This file was deleted.

14 changes: 0 additions & 14 deletions Guardfile

This file was deleted.

2 changes: 0 additions & 2 deletions Procfile

This file was deleted.

93 changes: 93 additions & 0 deletions README-devops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
## Overview

The Talkable documentation stack is a containerized system that uses Docker to simplify deployment and management. It is designed to generate, serve, and manage static documentation across multiple environments, such as staging and production.

## Key Features

1. **Containerized Components**:

- **Nginx**: Handles HTTP requests, serves static HTML files, manages URL redirection, and dynamically serves environment-specific `robots.txt` files.
- **Sphinx Autobuilder**: Generates static HTML files from source documentation and stores them in a persistent volume shared with Nginx.

2. **Environment-Specific Behavior**:

- Configured via a `.env` file for flexibility.
- Supports dynamic environment-specific behavior, such as serving different `robots.txt` files based on the `ENVIRONMENT` variable.

3. **Efficient Architecture**:

- Deployed on Amazon AWS Virtual Private Servers (VPS) with an AWS load balancer directing user traffic to the appropriate environment.
- Sphinx generates content on a persistent volume that Nginx serves directly.

## Deployment Process

### Prerequisites

- Ensure Docker and Docker Compose are installed on the target VPS.
- Clone the repository containing the stack configuration.

### Steps

1. **Clone the Repository**:

```bash
git clone [email protected]:talkable/talkable-docs.git
```

2. **Switch to the Appropriate Branch**:

- Use the `master` branch for production.

```bash
git checkout master
```

- Use the `staging` branch for staging.

```bash
git checkout staging
```

3. **Create and Configure the `.env` File**:

- Copy `.env.template` to `.env`:

```bash
cp .env.template .env
```

- Update the following variables:

- **`ENVIRONMENT`**: Set to `development`, `staging`, or `production`.
- **`LOCAL_PORT`**: Adjust if the default port (`8080`) is already in use.
- Leave `_HOST` variables unchanged unless domain names for staging or production servers are updated.

4. **Deploy the Stack**:

```bash
docker compose up -d --build
```

## Environment-Specific Configuration

### Handling `robots.txt`

- The repository includes separate `robots.txt` files for each environment.
- The correct file is dynamically selected based on the `ENVIRONMENT` variable and mapped to the container:

```yaml
volumes:
- ./nginx/robots/${ENVIRONMENT}.txt:/var/www/robots.txt
```

- Nginx serves the file at `/var/www/robots.txt` in response to `robots.txt` requests.

## Persistent Data Sharing

- **Static HTML Files**:
- Generated by Sphinx and stored in a shared volume.
- Served by Nginx without regeneration.

- **Volume Management**:
- Shared volumes allow seamless access and updates between containers.
- Ensures efficient and consistent behavior across environments.
Loading