Skip to content

Commit

Permalink
add a dockerfile so this isn't so annoying to build from scratch (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahmccuan authored Jun 16, 2024
1 parent 064f4e2 commit 657371a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.8-slim

WORKDIR /usr/src/app

COPY requirements.txt ./

RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt

COPY . .

RUN ["python", "scripts/normalize.py"]

RUN ["python", "scripts/validate.py", ">", "test_results.txt"]

RUN ["python", "build-html.py"]

WORKDIR /usr/src/app/docs

CMD ["python", "-m", "http.server"]
2 changes: 1 addition & 1 deletion build-html.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ def wrap_title(title: str, id = ''):
print(body)
html = '\n'.join([HEADER, body, FOOTER])

with open('docs/index.html', 'w', encoding="utf-8") as f:
with open('docs/greekwar.html', 'w', encoding="utf-8") as f:
f.write(html)
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
text_validator
pathlib
greek-normalisation
markdown
16 changes: 8 additions & 8 deletions scripts/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def normalize_file(filename):
print('Error: ' + str(sys.exc_info()[0]))

# relative path logic
chambers_path = Path(__file__).parent.parent
files_dir = (chambers_path / 'text\\').resolve()
files_list = glob.glob(str(files_dir) + '*.txt')
# chambers_path = Path(__file__).parent.parent
# files_dir = (chambers_path / 'text\\').resolve()
# files_list = glob.glob(str(files_dir) + '*.txt')

# normalize_file("C:/Users/Sarah McCuan/Documents/projects/ChambersGreekWar/drafts/chambers_ocr.md")
normalize_file("C:/Users/Sarah McCuan/Documents/projects/ChambersGreekWar/drafts/greek_english_vocab.md")
# instead of using the list above and potentially messing up in-progress files,
# it's easier to just individually specify what we want normalized:

# for file in files_list:
# normalize_file(file)
files_list = ['text/chambers_w_headers.txt', 'text/chambers.txt', 'docs/greek_english_vocab.html', 'docs/greekwar.html', 'docs/index.html']

# print(validate((chambers_path / 'text-validator.toml').resolve(), files_list))
for file in files_list:
normalize_file(file)
2 changes: 1 addition & 1 deletion scripts/validate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from text_validator.main import validate

validate("C:/Users/Sarah McCuan/Documents/projects/ChambersGreekWar/text-validator.toml", ["C:/Users/Sarah McCuan/Documents/projects/ChambersGreekWar/text/01.txt"])
validate("text-validator.toml", ["text/chambers_w_headers.txt"])

0 comments on commit 657371a

Please sign in to comment.