-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Root level images * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Update documentation * Update README.md * Update README.md * Update README.md * Add tna-python-dev image * Lint tna-python-dev Dockerfile * Fix shellcheck issues * Update CHANGELOG.md
- Loading branch information
Showing
24 changed files
with
347 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ARG BASE_IMAGE=ghcr.io/nationalarchives/tna-python-root | ||
ARG BASE_IMAGE_TAG=latest | ||
|
||
FROM "$BASE_IMAGE":"$BASE_IMAGE_TAG" | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
RUN apt-get update; \ | ||
apt-get install -y --no-install-recommends ca-certificates curl gnupg; \ | ||
install -m 0755 -d /etc/apt/keyrings; \ | ||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg; \ | ||
chmod a+r /etc/apt/keyrings/docker.gpg; \ | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; \ | ||
apt-get clean; \ | ||
apt-get autoremove -y --purge; \ | ||
rm -rfv /var/lib/apt/lists/* | ||
|
||
COPY --chown=app bin /home/app/.local/bin/dev | ||
RUN chmod +x -fR /home/app/.local/bin/dev | ||
ENV PATH="/home/app/.local/bin/dev:$PATH" | ||
|
||
COPY --chown=app lib/* /home/app/ | ||
|
||
CMD ["dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# tna-python-dev | ||
|
||
This image extends `tna-python` but adds: | ||
|
||
- `docker` - for managing other containers | ||
- `black`, `flake8` and `isort` - for formatting Python code | ||
- `prettier`, `eslint` and `stylelint` - for formatting JavaScript and CSS | ||
|
||
## Environment variables | ||
|
||
All environment variables defined in [tna-python](../tna-python/README.md). | ||
|
||
## Commands for the Dockerfile | ||
|
||
Run `help` from within the container to see a list of available commands. | ||
|
||
### `format` | ||
|
||
1. Run `isort` | ||
1. Run `black` | ||
1. Run `flake8` | ||
1. Apply prettier to all files in the `/app` directory | ||
1. Run `stylelint` against all SCSS files in the `/app` directory | ||
1. Run `eslint` against all JavaScript files in the `/app` directory | ||
|
||
### `secret-key` | ||
|
||
Generate a string that can be used as the environment variable `SECRET_KEY`: | ||
|
||
- https://docs.python.org/3/library/secrets.html | ||
- https://docs.djangoproject.com/en/dev/ref/settings/#secret-key | ||
- https://flask.palletsprojects.com/en/2.3.x/config/#SECRET_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
python -m pip install --quiet black==23.7.0 flake8==6.1.0 isort==5.12.0 | ||
|
||
cd /app || return | ||
|
||
. "$HOME/.nvm/nvm.sh" | ||
if [ -f "/app/.nvmrc" ] | ||
then | ||
nvm install | ||
else | ||
nvm use lts/iron | ||
fi | ||
npm install -g [email protected] [email protected] [email protected] [email protected] [email protected] | ||
|
||
welcome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
cd /app || return | ||
|
||
echo "Running isort..." | ||
isort --settings-file /home/app/.isort.cfg /app --overwrite-in-place | ||
echo | ||
|
||
echo "Running black..." | ||
black -t py38 -t py39 -t py310 -t py311 -t py312 --line-length 80 --verbose /app | ||
echo | ||
|
||
echo "Running flake8..." | ||
flake8 --config=/home/app/.flake8 /app | ||
echo | ||
|
||
. "$HOME/.nvm/nvm.sh" | ||
if [ -f "/app/.nvmrc" ] | ||
then | ||
nvm install | ||
else | ||
nvm use lts/iron | ||
fi | ||
|
||
echo "Running prettier..." | ||
prettier --write /app | ||
echo | ||
|
||
echo "Running stylelint..." | ||
if [ -f "/app/.stylelintrc" ] | ||
then | ||
echo "Using app config" | ||
stylelint --fix "/app/**/*.{css,scss}" | ||
else | ||
echo "Using default config" | ||
stylelint --config /home/app/.stylelintrc --fix "/app/**/*.{css,scss}" | ||
fi | ||
echo | ||
|
||
echo "Running eslint..." | ||
if [ -f "/app/.eslintrc.js" ] | ||
then | ||
echo "Using app config" | ||
eslint --fix "/app" | ||
else | ||
echo "Using default config" | ||
eslint -c /home/app/.eslintrc.js --fix "/app" | ||
fi | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
echo "==========================================" | ||
echo "TNA Python Dev" | ||
echo "------------------------------------------" | ||
echo "" | ||
echo "help" | ||
echo " Display all commands (this file)" | ||
echo "" | ||
echo "format" | ||
echo " Run isort, black and flake8 against the project Python files and prettier against the JavaScript and CSS" | ||
echo "" | ||
echo "upgrade" | ||
echo " Update the Poetry and Node dependencies" | ||
echo "" | ||
echo "tna-build" | ||
echo " Run the TNA build process" | ||
echo "" | ||
echo "tna-run" | ||
echo " Run the TNA run process" | ||
echo "" | ||
echo "tna-node" | ||
echo " Run a Node command from your package.json" | ||
echo "" | ||
echo "secret-key" | ||
echo " Generate a string that can be used as the environment variable SECRET_KEY" | ||
echo "" | ||
echo "==========================================" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python -c 'import secrets; print(secrets.token_hex())' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
cd /app || return | ||
|
||
poetry update | ||
|
||
. "$HOME/.nvm/nvm.sh" | ||
if [ -f "/app/.nvmrc" ] | ||
then | ||
nvm install | ||
else | ||
nvm use lts/iron | ||
fi | ||
npm update |
Oops, something went wrong.