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

Use the latest containers #1743

Merged
merged 28 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a2ca6bc
Use the latest containers
ahosgood Nov 5, 2024
47e2e89
Refactor fabfile.py into dev scripts for tna-python-dev
ahosgood Nov 25, 2024
cb48f60
Merge branch 'develop' of github.com:nationalarchives/ds-wagtail into…
ahosgood Nov 25, 2024
0ebbced
Remove custom run command from app
ahosgood Nov 25, 2024
abaccd7
Tidy up dev commands
ahosgood Nov 25, 2024
4ce907d
Ignore fabfile.py
ahosgood Nov 27, 2024
fa66c17
Merge branch 'develop' into feature/new-dev-image
ahosgood Dec 16, 2024
a28d7f0
Use latest stable dev Docker image
ahosgood Dec 16, 2024
ff5b634
Use preview dev Docker image
ahosgood Dec 16, 2024
5c32024
Ignore more directories for stylelint
ahosgood Dec 16, 2024
2aea4f5
Merge branch 'develop' of github.com:nationalarchives/ds-wagtail into…
ahosgood Jan 3, 2025
b329a16
Only install and log into Platform.sh CLI if not already set up
ahosgood Jan 3, 2025
78b1a80
Replace more domains in DB dump when migrating down content
ahosgood Jan 3, 2025
54dd3f0
Add stylelint-order
ahosgood Jan 3, 2025
99463cb
Merge branch 'develop' into feature/new-dev-image
ahosgood Jan 6, 2025
3089c8d
Update docs
ahosgood Jan 6, 2025
b21b8db
Linting and formatting
ahosgood Jan 6, 2025
2e57901
Add ignores and excludes to some broken SCSS and JS files, add TODO f…
ahosgood Jan 6, 2025
71751a7
Remove Prettier from CI/CD, remove stylelint from dependencies
ahosgood Jan 6, 2025
37124fe
Remove setup.cfg
ahosgood Jan 6, 2025
b149d7f
Update CI test order
ahosgood Jan 6, 2025
5892695
Update isort profile
ahosgood Jan 6, 2025
e5b0c96
Update line lengths
ahosgood Jan 6, 2025
f21063f
Fixed line lengths
ahosgood Jan 6, 2025
8703a3f
Remove flake8 config from CI/CD
ahosgood Jan 6, 2025
805d779
Update Poetry lock file
ahosgood Jan 6, 2025
db1aade
Fix Black line length definition
ahosgood Jan 6, 2025
616f91d
Fix all new line lengths
ahosgood Jan 6, 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
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
omit =
config/*
docs/*
dev/*
etna/**/migrations/*
etna/**/tests/*
fabfile.py
gunicorn.conf.py
manage.py
source = .
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
Dockerfile
README.md
babel.config.json
database_dumps
dev
docker-compose.yml
docs
fabfile.py
gunicorn.conf.py
lint-requirements.txt
media
Expand Down
8 changes: 0 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
DATABASE_ENGINE=django.db.backends.postgresql
DATABASE_NAME=postgres
DATABASE_USER=postgres
DATABASE_HOST=db
PLATFORM_PROJECT_ID=
KONG_CLIENT_BASE_URL=
KONG_IMAGE_PREVIEW_BASE_URL=
KONG_CLIENT_KEY=
KONG_CLIENT_VERIFY_CERTIFICATES=True
KONG_CLIENT_TEST_MODE=False
KONG_CLIENT_TEST_FILENAME=records.json
PLATFORMSH_CLI_TOKEN=your-api-token-here
11 changes: 7 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ module.exports = {
env: {
browser: true,
es2021: true,
jquery: true,
jest: true,
},
extends: ["eslint:recommended"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js}"],
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
Expand All @@ -22,5 +20,10 @@ module.exports = {
sourceType: "module",
},
rules: {},
ignorePatterns: ["templates/static/scripts/**/*.js", ".*.js", "*.config.js"],
ignorePatterns: [
"templates/static/scripts/**/*.js",
".*.js",
"*.config.js",
"static",
],
};
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
ignore = E203, E266, E501, W503, F403, F401
exclude = venv*,__pycache__,node_modules,migrations
max-line-length = 80
max-complexity = 12
select = B,C,E,F,W,T4,B9
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ templates/static
/static/*
!/static/.gitkeep

# Ignore the contents of /database_dumps but keep the directory
/database_dumps/*
!/database_dumps/.gitkeep

# Database backups
/db/

Expand Down
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
profile=hug
skip=migrations
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Ignore all HTML files:
**/*.html
**/*.html
etna/api/tests/expected_results/**/*
27 changes: 0 additions & 27 deletions .stylelintrc

This file was deleted.

42 changes: 4 additions & 38 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,28 @@
"version": "2.0.0",
"tasks": [
{
"label": "fab start",
"label": "Start",
"type": "shell",
"command": "fab start",
"presentation": {
"close": true
},
},
{
"label": "fab build",
"type": "shell",
"command": "fab build",
"command": "docker compose up -d",
"presentation": {
"close": true
},
},
{
"label": "Pull staging",
"type": "shell",
"command": "fab pull-staging-data && fab pull-staging-media",
"command": "docker compose exec dev pull",
"presentation": {
"close": true
},
},
{
"label": "Pull production",
"type": "shell",
"command": "fab pull-production-data && fab pull-production-media",
"command": "docker compose exec dev pull main",
"presentation": {
"close": true
}
},
{
"label": "Full build (staging)",
"type": "shell",
"presentation": {
"close": true
},
"dependsOrder": "sequence",
"dependsOn": [
"fab build",
"fab start",
"Pull staging"
]
},
{
"label": "Full build (production)",
"type": "shell",
"presentation": {
"close": true
},
"dependsOrder": "sequence",
"dependsOn": [
"fab build",
"fab start",
"Pull production"
]
},
],
}
31 changes: 15 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
FROM ghcr.io/nationalarchives/tna-python-django:latest
ARG IMAGE=ghcr.io/nationalarchives/tna-python-django
ARG IMAGE_TAG=latest

ENV NPM_BUILD_COMMAND=compile
ENV DJANGO_SETTINGS_MODULE=config.settings.production
FROM "$IMAGE":"$IMAGE_TAG"

HEALTHCHECK CMD curl --fail http://localhost:8080/healthcheck/ || exit 1
ENV NPM_BUILD_COMMAND=compile
ARG BUILD_VERSION
ENV BUILD_VERSION="$BUILD_VERSION"

# Copy in the project dependency files and config
COPY --chown=app pyproject.toml poetry.lock ./
COPY --chown=app package.json package-lock.json .nvmrc webpack.config.js ./
COPY --chown=app sass sass
COPY --chown=app scripts scripts
COPY --chown=app config config
COPY --chown=app templates templates
# Copy in the application code
COPY --chown=app . .

# Install Python dependencies AND the 'etna' app
# Install dependencies
RUN tna-build

# Copy application code
COPY --chown=app . .

# Copy the assets from the @nationalarchives/frontend repository
# TODO: Remove once completely headless
RUN mkdir -p /app/templates/static/assets; \
cp -R /app/node_modules/@nationalarchives/frontend/nationalarchives/assets/* /app/templates/static/assets
cp -R /app/node_modules/@nationalarchives/frontend/nationalarchives/assets/* /app/templates/static/assets; \
poetry run python /app/manage.py collectstatic --no-input --clear

# Delete source files, tests and docs
# RUN rm -fR /app/src /app/test /app/docs

CMD ["tna-run", "config.wsgi:application"]
64 changes: 8 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
This project contains technical documentation written in Markdown in the /docs folder. The latest build (from the `develop` branch) can be viewed online at:
https://nationalarchives.github.io/ds-wagtail/


You can also view it locally on http://localhost:8001/ which is booted as the `docs` container.

## Setting up a local build
Expand All @@ -24,76 +23,29 @@ Once installed, you can type `fab -l` to see a list of available commands.
cp .env.example .env
```

### 1. Build and start Docker containers
Populate values for:

```sh
fab start
```
- `KONG_CLIENT_BASE_URL`
- `KONG_IMAGE_PREVIEW_BASE_URL`
- `KONG_CLIENT_KEY`
- `PLATFORMSH_CLI_TOKEN`

This command takes care of the following:

1. Building all of the necessary Docker containers
2. Starting all of the necessary Docker containers
3. Installing any new python dependencies
4. Collect static assets

### 2. Start the development server
### 1. Build and start Docker containers

```sh
# Enter the shell for the web container
fab sh

# Run migrations
poetry run python manage.py migrate

# Run the development server
poetry run python manage.py runserver 0.0.0.0:8000
docker compose up -d
```

### 2. Access the site

<http://127.0.0.1:8000>

### 3. Create a Django user for yourself

```sh
# ...from within the web container
python manage.py createsuperuser

# ...or on the host machine
fab create-superuser
```

### 4. Access the Wagtail admin
### 3. Access the Wagtail admin

Navigate to the admin URL in your browser, and sign in using the username/password combination you chose in the previous step.

<http://127.0.0.1:8000/admin/>

### 5. Compile the front-end assets
See https://nationalarchives.github.io/ds-wagtail/developer-guide/frontend/#setting-up-the-front-end-development-environment

## Linux / OSX
If you are running a Unix based operating system, these alias commands may be useful to you to run inside the Docker container.

Running the development server:

``` sh
djrun
```

Run migrations:

```sh
dj migrate
```

Create a super user:

```sh
dj createsuperuser
```

## Issues with your local environment?

Check out the [Local development gotchas](https://nationalarchives.github.io/ds-wagtail/developer-guide/local-development-gotchas/) page for solutions to common issues.
Expand Down
7 changes: 0 additions & 7 deletions bash/bashrc.sh

This file was deleted.

5 changes: 0 additions & 5 deletions bash/run-dev.sh

This file was deleted.

Empty file removed database_dumps/.gitkeep
Empty file.
26 changes: 0 additions & 26 deletions dev/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions dev/bin/build

This file was deleted.

3 changes: 0 additions & 3 deletions dev/bin/build-css

This file was deleted.

3 changes: 0 additions & 3 deletions dev/bin/build-js

This file was deleted.

3 changes: 0 additions & 3 deletions dev/bin/createsuperuser

This file was deleted.

4 changes: 0 additions & 4 deletions dev/bin/dev

This file was deleted.

3 changes: 0 additions & 3 deletions dev/bin/dev-css

This file was deleted.

3 changes: 0 additions & 3 deletions dev/bin/dev-js

This file was deleted.

Loading
Loading