Skip to content

Commit 2301bca

Browse files
authored
Merge pull request #55 from nyu-devops/sp25-updates
Updates for Sprint 2025 Semester
2 parents c86b5ea + 438bb5b commit 2301bca

File tree

13 files changed

+941
-1364
lines changed

13 files changed

+941
-1364
lines changed

.devcontainer/Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# cspell: disable
12
# Image for a Python 3 development environment
23
FROM python:3.11-slim
34

4-
# Add any tools that are needed beyond Python 3.9
5+
# Add any tools that are needed beyond Python 3.11
56
RUN apt-get update && \
6-
apt-get install -y sudo vim make git zip tree curl wget jq && \
7+
apt-get install -y sudo vim make git zip tree curl wget jq procps net-tools && \
78
apt-get autoremove -y && \
89
apt-get clean -y
910

@@ -12,21 +13,21 @@ ARG USERNAME=devops
1213
ARG USER_UID=1000
1314
ARG USER_GID=$USER_UID
1415

15-
# Create the user with passwordless sudo privileges
16+
# Create the user with password-less sudo privileges
1617
RUN groupadd --gid $USER_GID $USERNAME \
1718
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
1819
&& usermod -aG sudo $USERNAME \
1920
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
20-
&& chmod 0440 /etc/sudoers.d/$USERNAME
21+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
22+
&& chown -R $USERNAME:$USERNAME /home/$USERNAME
2123

2224
# Set up the Python development environment
2325
WORKDIR /app
24-
COPY pyproject.toml poetry.lock ./
25-
RUN python -m pip install poetry && \
26-
poetry config virtualenvs.create false && \
27-
poetry install
26+
COPY Pipfile Pipfile.lock ./
27+
RUN python -m pip install -U pip pipenv && \
28+
pipenv install --system --dev
2829

29-
ENV PORT 8000
30+
ENV PORT=8000
3031
EXPOSE $PORT
3132

3233
# Enable color terminal for docker exec bash

.devcontainer/devcontainer.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"customizations": {
99
"vscode": {
1010
"settings": {
11+
"cSpell.words": [
12+
"wsgi",
13+
"pytest",
14+
"Redis",
15+
"testdb"
16+
],
1117
"[python]": {
1218
"editor.defaultFormatter": "ms-python.black-formatter",
1319
"editor.formatOnSave": true
@@ -33,21 +39,25 @@
3339
"ms-python.pylint",
3440
"ms-python.flake8",
3541
"ms-python.black-formatter",
42+
"njpwerner.autodocstring",
43+
"wholroyd.jinja",
3644
"ms-vscode.makefile-tools",
3745
"yzhang.markdown-all-in-one",
46+
"davidanson.vscode-markdownlint",
3847
"bierner.github-markdown-preview",
3948
"hnw.vscode-auto-open-markdown-preview",
40-
"DavidAnson.vscode-markdownlint",
49+
"bierner.markdown-preview-github-styles",
50+
"tamasfe.even-better-toml",
4151
"donjayamanne.githistory",
4252
"GitHub.vscode-pull-request-github",
4353
"hbenl.vscode-test-explorer",
4454
"LittleFoxTeam.vscode-python-test-adapter",
45-
"njpwerner.autodocstring",
4655
"redhat.vscode-yaml",
47-
"rangav.vscode-thunder-client",
48-
"streetsidesoftware.code-spell-checker",
49-
"wholroyd.jinja",
50-
"ms-azuretools.vscode-docker"
56+
"unjinjang.rest-api-client",
57+
"ms-azuretools.vscode-docker",
58+
"github.vscode-github-actions",
59+
"streetsidesoftware.code-spell-checker",
60+
"bbenoist.vagrant"
5161
]
5262
}
5363
}

.devcontainer/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ services:
1515
environment:
1616
FLASK_APP: wsgi:app
1717
FLASK_DEBUG: "True"
18-
GUNICORN_BIND: "0.0.0.0:8000"
19-
PORT: 8000
18+
GUNICORN_BIND: "0.0.0.0:8080"
19+
PORT: 8080
2020
DATABASE_URI: "redis://redis:6379"
2121
networks:
2222
- dev

.github/workflows/workflow.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ jobs:
3030
- name: Checkout
3131
uses: actions/checkout@v3
3232

33-
- name: Install dependencies
33+
- name: Install Python package dependencies
3434
run: |
35-
python -m pip install poetry
36-
poetry config virtualenvs.create false
37-
poetry install
35+
python -m pip install -U pip pipenv
36+
pipenv install --system --dev
3837
3938
- name: Linting
4039
run: |
@@ -53,8 +52,7 @@ jobs:
5352
# Create a CODECOV_TOKEN in Settings->Secrets and variables->Actions
5453
# and then uncomment the CodeCov action during hands-on lab
5554

56-
- name: Upload coverage reports to Codecov
57-
uses: codecov/[email protected]
58-
with:
59-
token: ${{ secrets.CODECOV_TOKEN }}
60-
55+
# - name: Upload coverage reports to Codecov
56+
# uses: codecov/[email protected]
57+
# with:
58+
# token: ${{ secrets.CODECOV_TOKEN }}

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ FROM python:3.11-slim
33
# Establish a working folder
44
WORKDIR /app
55

6-
# Establish dependencies
7-
COPY pyproject.toml poetry.lock ./
8-
RUN python -m pip install poetry && \
9-
poetry config virtualenvs.create false && \
10-
poetry install --without dev
11-
6+
# Establish dependencies without dev tools
7+
COPY Pipfile Pipfile.lock ./
8+
RUN python -m pip install -U pip pipenv && \
9+
pipenv install --system
10+
1211
# Copy source files last because they change the most
1312
COPY wsgi.py .
1413
COPY service ./service

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
1-
.PHONY: all help install venv test run
2-
31
help: ## Display this help
42
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-\\.]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
53

4+
.PHONY: all
65
all: help
76

87
##@ Development
98

9+
.PHONY: clean
10+
clean: ## Clean up test files
11+
$(info Cleaning up test files...)
12+
-rm .coverage coverage.xml unittests.xml
13+
-rm -fr .pytest_cache dist build
14+
15+
.PHONY: venv
1016
venv: ## Create a Python virtual environment
1117
$(info Creating Python 3 virtual environment...)
12-
poetry config virtualenvs.in-project true
13-
poetry shell
18+
PIPENV_VENV_IN_PROJECT=1 pipenv shell
1419

20+
.PHONY: install
1521
install: ## Install dependencies
1622
$(info Installing dependencies...)
17-
poetry install
23+
PIPENV_VENV_IN_PROJECT=1 pipenv install
1824

25+
.PHONY: lint
1926
lint: ## Run the linter
2027
$(info Running linting...)
2128
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
2229
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
2330
pylint service tests --max-line-length=127
2431

32+
.PHONY: test
2533
test: ## Run the unit tests
2634
$(info Running tests...)
2735
pytest --pspec --cov=service --cov-fail-under=95
2836

2937
##@ Runtime
3038

39+
.PHONY: run
3140
run: ## Run the service
3241
$(info Starting service...)
3342
honcho start

Pipfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
flask = "==3.1.0"
8+
retry2 = "==0.9.5"
9+
python-dotenv = "==1.0.1"
10+
gunicorn = "==23.0.0"
11+
redis = "==5.2.1"
12+
flask-redis = "==0.4.0"
13+
14+
[dev-packages]
15+
honcho = "~=2.0.0"
16+
pylint = "~=3.3.4"
17+
flake8 = "~=7.1.1"
18+
black = "~=25.1.0"
19+
pytest = "~=8.3.4"
20+
pytest-pspec = "~=0.0.4"
21+
pytest-cov = "~=6.0.0"
22+
factory-boy = "~=3.3.3"
23+
coverage = "~=7.6.12"
24+
httpie = "~=3.2.4"
25+
26+
[requires]
27+
python_version = "3.11"

0 commit comments

Comments
 (0)