Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/GH-56-highlight-active-redirect-link
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Apr 22, 2021
2 parents 33c34e0 + 3deb6b4 commit 7e4abb4
Show file tree
Hide file tree
Showing 152 changed files with 14,658 additions and 3,599 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

---


20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build

## environment variables
.env
docker_repo.var

# Static and Media folders
/static
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "taccsite_custom"]
path = taccsite_custom
url = git@github.com:TACC/cms-site-resources.git
url = git@github.com:TACC/Core-CMS-Resources.git
branch = task/37-per-site-assets
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKERHUB_REPO := taccwma/$(shell cat ./repo_name.var)
DOCKERHUB_REPO := taccwma/$(shell cat ./docker_repo.var)
DOCKER_TAG ?= $(shell git rev-parse --short HEAD)
DOCKER_IMAGE := $(DOCKERHUB_REPO):$(DOCKER_TAG)
DOCKER_IMAGE_LATEST := $(DOCKERHUB_REPO):latest
Expand Down
79 changes: 67 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
# TACC CMS
# TACC CORE-CMS

## Docker Setup

A TACC CMS can be run using Docker and Docker Compose both locally or in production.
The TACC CORE-CMS can be run using Docker and Docker Compose, both locally and in production.

## Configuration

### Required

1. Create a `.env` at the root of the project, with the content `CUSTOM_ASSET_DIR=example-cms`.
1. Initialize submodules and retireve the latest relevant code.
1. `git submodule init` (only necessary once)
- Add `cms-site-resources` repo as `taccsite_custom/`.
2. `git submodule update`
- Get latest desired submodule commit (this adds directory content).
1. Create a `.env` with this content\* at the root of the project:

```bash
CUSTOM_ASSET_DIR=example-cms
```

\* Where `example-cms` is the project to be run. _See [(Optional) Custom Resources per CMS Project](#optional-custom-resources-per-cms-project)._
1. Initialize / Update submodules.
1. `git submodule init`\
_(Adds `cms-site-resources` repo as submodule at `taccsite_custom/`. Only necessary once per `CORE-cms` repo clone.)_
2. `git submodule update`\
_(Downloads code from pinned commit of `cms-site-resources` repo to `taccsite_custom/`.)_
3. (as necessary) Change the pinned commit of submodule.\
_(Downloads code from different commit of `cms-site-resources` repo to `taccsite_custom/`.)_

```bash
# Navigate into submodule (from root of this repo)
cd taccsite_custom
# Checkout different commit of submodule repo
git checkout master_or_other_branch_or_commit
# Update commit of submodule repo (as necessary)
git pull # (or git fetch […], etc.)
```

4. (as necessary) Save/Commit the pinned commit of submodule.\
_(Updates the pinned commit of `cms-site-resources` repo at `taccsite_custom/`.)_

```bash
# Navigate back to this repo (from root of submodule repo)
cd ../
# Commit this repo's pointer to a different commit of submodule repo
git add taccsite_custom
git commit -m "[…] Update submodule to get […]"
```

<!-- IDEA: For brevity, consider moving steps 3 and 4 to a different section or document -->

### For Isolated Instance Like Production

Expand Down Expand Up @@ -164,7 +194,7 @@ Certain static files are built __from__ source files __in__ `src` directories __
> __Notice__: If you are using a `docker-compose.custom.yml`, then replace this command's `taccsite_cms` with that file's `cms`: `hostname`.

```bash
docker exec -it taccsite_cms /bin/bash
docker exec -it core_cms /bin/bash
```

_It is __not__ necessary to run the next commands in the Docker container, but it does completely __isolate development__ and __mimic production__._
Expand Down Expand Up @@ -198,7 +228,7 @@ Whenever static files are changed, the CMS may need to be manually told to serve
> __Notice__: If you are using a `docker-compose.custom.yml`, then replace this command's `taccsite_cms` with that file's `cms`: `hostname`.

```bash
docker exec -it taccsite_cms /bin/bash
docker exec -it core_cms /bin/bash
```

2. [Collect static files][django-static] for Django:
Expand All @@ -216,8 +246,33 @@ Whenever static files are changed, the CMS may need to be manually told to serve
5. (For templates) Restart server.
6. Commit changes:
1. In `/taccsite_custom` submodule repo, commit changes (__not__ to `master`).
2. In `cms-site-template` parent repo, add `/taccsite_custom` change.
3. In `cms-site-template` parent repo, commit changes (__not__ to `master`).
2. In this parent repo, add `/taccsite_custom` change.
3. In this parent repo, commit changes (__not__ to `main`).

## How to Run Tests

### Test TACC CMS Plugins

Testing is run through Django. From within `core_cms` container, run `python manage.py test PATH_TO_DIR_WITH_TESTS` from the repository root directory. Example:

```bash
docker exec -it core_cms /bin/bash
python manage.py test taccsite_cms.contrib.taccsite_sample
```

> __Notice__: To test without migrations—which is _much_ faster—add the flag `--nomigrations` (or `-n`). Example:
>
> ```bash
> docker exec -it core_cms /bin/bash
> python manage.py test taccsite_cms.contrib.taccsite_sample --nomigrations
> ```

<!-- TODO: Make `python manage.py test` recursively find all the tests -->
<!-- SEE: https://docs.djangoproject.com/en/2.2/topics/testing/overview/#running-tests -->

### Test PostCSS Plugin Configs

Testing is manual review of build output. From within `core_cms` container, run `npm run build` from the repository root directory, then review `taccsite_cms/static/site_cms/css/build/_test.css`.

## Reference

Expand Down
22 changes: 22 additions & 0 deletions conf/css/.postcssrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins:
postcss-import:
path:
- './taccsite_cms/static/site_cms/css/src'
postcss-extend: {}
postcss-preset-env:
# SEE: https://github.com/csstools/postcss-preset-env#features
stage: false
# SEE: https://github.com/csstools/postcss-preset-env/blob/master/src/lib/plugins-by-id.js#L35
features:
custom-media-queries: true
media-query-ranges: true
cssnano:
preset:
- 'default'
-
# Both of these are disabled to allow manual CSS build tests
# The `discardDuplicates` is disabled to prevent hiding duplicate CSS
discardDuplicates:
exclude: true
mergeRules:
exclude: true
8 changes: 8 additions & 0 deletions conf/css/freeze_variables/.postcssrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins:
postcss-import:
path:
- './taccsite_cms/static/site_cms/css/src'
postcss-css-variables:
preserve: 'computed'
preserveAtRulesOrder: true
cssnano: {}
9 changes: 9 additions & 0 deletions docs/404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
permalink: /404.html
---

# 404 ERROR

## TACC ACI WMA Core-CMS GitPages

Page not found...
93 changes: 93 additions & 0 deletions docs/PostgreSQL_database_manual_update_procedures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Migrating SAD CMS Site PostgreSQL Databases from 9.2 to 13.1

This is a comprehensive replacement of the databse, not an upgrade.

## A) BACKUP EXISTING DATABASE

1. ssh into host
2. become sudo: `sudo su`
3. become postgres user: `sudo su - postgres`
4. dump the database: `pg_dumpall > ~/DB_BACKUP_FILE.sql`
- Note: use a descriptive name for the dump file (eg. `texascale_org_prod_20201204.sql`).
5. move the backup to the `/tmp` folder for now: ` mv DB_BACKUP_FILE.sql /tmp/`

## B) UPDATE THE HOST

1. ssh into host
2. become sudo: `sudo su`
3. update all packages: `yum update -y`
- NOTE: Servers running the old SAD configuration will need to also install the new ldap modules: `sudo yum install python-devel openldap-devel -y`
4. reboot the system to let kernel updates take effect: `reboot now`

## C) DISABLE THE OLD POSTGRESQL 9.2 DATABASE

1. ssh into host
2. become sudo: `sudo su`
3. disable OLD databese service: `systemctl disable postgresql`

## D) INSTALL & INITIALIZE THE NEW POSTGRESQL 13.1 DATABASE

1. ssh into host
2. become sudo: `sudo su`
3. add repo for packages: `yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm`
4. install packages: `yum -y install postgresql13 postgresql13-server`
5. intialize database: `/usr/pgsql-13/bin/postgresql-13-setup initdb`
6. Edit the `pg_hba.conf` file for the correct server IP and method types: `vim /var/lib/pgsql/13/data/pg_hba.conf`
7. start database service: `systemctl start postgresql-13`
8. check database status: `systemctl status postgresql-13`
9. set service to autorun as host reboot: `systemctl enable postgresql-13`
10. Reboot the server: `sudo reboot now`

### pg_hba.conf example:

```
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
#local all all peer
#local all all md5
local all all trust
# Accept from anywhere (development and testing use ONLY!).
host all all 0.0.0.0/0 md5
# Accept from trusted subnet (production setting).
# UPDATE SERVER IP TO REFLECT HOST.
host all all 129.114.60.24/24 md5
# IPv4 local connections:
#host all all 127.0.0.1/32 scram-sha-256
host all all 127.0.0.1/32 md5
# IPv6 local connections:
#host all all ::1/128 scram-sha-256
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
#host replication all 127.0.0.1/32 scram-sha-256
host repliction all 127.0.0.1/32 md5
#host replication all ::1/128 scram-sha-256
host replication all ::1/128 md5
```

## E) RESTORE DATA TO NEW DB

1. ssh into host
2. become sudo: `sudo su`
3. verify the database is running: `systemctl status postgresql-13`
4. become postgres user: `sudo su - postgres`
5. restore the database dump: `psql --set ON_ERROR_STOP=on -f /tmp/DB_BACKUP_FILE.sql`
- NOTE: if you encounter errors during the restore, check that the correct password has been applied to the postgresadmin user (compare to the value in `/srv/taccsite/taccsite_cms/secrets.py`).
6. start psql: `psql`
7. verify the database exists with the correct users: `\l`
8. verify the users exist: `\du`
9. apply roles to postgresadmin user: `ALTER ROLE postgresadmin WITH CREATEDB CREATEROLE INHERIT LOGIN REPLICATION;`
10. verify the users exist with the correct roles granted: `\du`
11. connect to the database: `\c taccsite`
12. verify that the database is populated with the expected tables: `\dt`
13. exit psql: `\q`

## F) RESUME STEPS FOR USING CMS BRANCH AND SUBMODULE

Steps for the subsequent actions can be found here: (get notes for this from Wesley)
6 changes: 6 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
theme: jekyll-theme-minimal
title: TACC Core-CMS
description: The TACC ACI-WMA Core-CMS codebase used to generate branded CMS container images for all TACC portal projects.
logo: /assets/img/tacc.logo.x128.png
show_downloads: true
google_analytics: ##-########-##
Loading

0 comments on commit 7e4abb4

Please sign in to comment.