Skip to content

Commit 6fde234

Browse files
authored
Merge pull request #31 from nyu-devops/sp25-updates
Updates for Spring 2025 Semester
2 parents 3efafa6 + d7c45dc commit 6fde234

File tree

11 files changed

+938
-114
lines changed

11 files changed

+938
-114
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM python:3.11-slim
33

44
# Add any tools that are needed beyond Python 3.11
55
RUN apt-get update && \
6-
apt-get install -y sudo vim make git zip tree curl wget jq procps net-tools && \
6+
apt-get install -y sudo vim make git zip tree curl wget jq procps net-tools iputils-ping && \
77
apt-get autoremove -y && \
88
apt-get clean -y
99

@@ -12,7 +12,7 @@ ARG USERNAME=vscode
1212
ARG USER_UID=1000
1313
ARG USER_GID=$USER_UID
1414

15-
# Create the user with passwordless sudo privileges
15+
# Create the user with password-less sudo privileges
1616
RUN groupadd --gid $USER_GID $USERNAME \
1717
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
1818
&& usermod -aG sudo $USERNAME \
@@ -22,10 +22,12 @@ RUN groupadd --gid $USER_GID $USERNAME \
2222

2323
# Set up the Python development environment
2424
WORKDIR /app
25-
COPY pyproject.toml poetry.lock ./
26-
RUN sudo python -m pip install --upgrade pip poetry && \
27-
sudo poetry config virtualenvs.create false && \
28-
sudo poetry install
25+
COPY Pipfile Pipfile.lock ./
26+
RUN python -m pip install --upgrade pip pipenv && \
27+
pipenv install --system --dev
28+
29+
ENV PORT=8080
30+
EXPOSE $PORT
2931

3032
ENV PORT 8080
3133
EXPOSE $PORT

.devcontainer/devcontainer.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// spell: disable
22
{
3-
"name": "Kubernetes",
3+
"name": "Kubernetes Lab",
44
"build": {
55
"dockerfile": "Dockerfile",
66
"context": ".."
@@ -18,13 +18,20 @@
1818
"customizations": {
1919
"vscode": {
2020
"settings": {
21+
"cSpell.words": [
22+
"pytest",
23+
"pipenv",
24+
"creds",
25+
"virtualenvs"
26+
],
2127
"[python]": {
2228
"editor.defaultFormatter": "ms-python.black-formatter",
2329
"editor.formatOnSave": true
2430
},
2531
"git.mergeEditor": true,
2632
"markdown-preview-github-styles.colorTheme": "light",
2733
"makefile.extensionOutputFolder": "/tmp",
34+
"makefile.configureOnOpen": false,
2835
"python.testing.unittestEnabled": false,
2936
"python.testing.pytestEnabled": true,
3037
"python.testing.pytestArgs": [
@@ -44,6 +51,8 @@
4451
"ms-python.pylint",
4552
"ms-python.flake8",
4653
"ms-python.black-formatter",
54+
"njpwerner.autodocstring",
55+
"wholroyd.jinja",
4756
"ms-vscode.makefile-tools",
4857
"yzhang.markdown-all-in-one",
4958
"DavidAnson.vscode-markdownlint",
@@ -56,13 +65,11 @@
5665
"github.vscode-github-actions",
5766
"hbenl.vscode-test-explorer",
5867
"LittleFoxTeam.vscode-python-test-adapter",
59-
"njpwerner.autodocstring",
60-
"wholroyd.jinja",
6168
"redhat.vscode-yaml",
69+
"unjinjang.rest-api-client",
6270
"ms-azuretools.vscode-docker",
6371
"ms-kubernetes-tools.vscode-kubernetes-tools",
6472
"inercia.vscode-k3d",
65-
"rangav.vscode-thunder-client",
6673
"streetsidesoftware.code-spell-checker",
6774
"bbenoist.vagrant"
6875
]

.devcontainer/scripts/install-tools.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sudo sh -c 'echo "127.0.0.1 cluster-registry" >> /etc/hosts'
2424
echo "**********************************************************************"
2525
echo "Installing K9s..."
2626
echo "**********************************************************************"
27-
curl -L -o k9s.tar.gz "https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_Linux_$ARCH.tar.gz"
27+
curl -L -o k9s.tar.gz "https://github.com/derailed/k9s/releases/download/v0.32.7/k9s_Linux_$ARCH.tar.gz"
2828
tar xvzf k9s.tar.gz
2929
sudo install -c -m 0755 k9s /usr/local/bin
3030
rm k9s.tar.gz
@@ -40,3 +40,7 @@ echo "Installing DevSpace..."
4040
echo "**********************************************************************"
4141
curl -Lo devspace "https://github.com/loft-sh/devspace/releases/latest/download/devspace-linux-$ARCH"
4242
sudo install -c -m 0755 devspace /usr/local/bin
43+
44+
echo "\n\n**********************************************************************"
45+
echo "Tools Installation Complete!"
46+
echo "**********************************************************************"

.devcontainer/scripts/setup-lab.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
2+
echo "**********************************************************************"
23
echo "Setting up Kubernetes lab environment..."
4+
echo "**********************************************************************\n"
5+
36
docker pull python:3.11-slim
47
docker run -d --name redis --restart always -p 6379:6379 -v redis:/data redis:6-alpine
58

@@ -9,4 +12,6 @@ sudo bash -c "echo '127.0.0.1 cluster-registry' >> /etc/hosts"
912
echo "Make git stop complaining about unsafe folders..."
1013
git config --global --add safe.directory /app
1114

15+
echo "\n**********************************************************************"
1216
echo "Setup complete"
17+
echo "**********************************************************************"

.github/workflows/workflow.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v3
3636

37-
- name: Install dependencies
37+
- name: Install Python package dependencies
3838
run: |
39-
python -m pip install poetry
40-
poetry config virtualenvs.create false
41-
poetry install
39+
python -m pip install -U pip pipenv
40+
pipenv install --system --dev
4241
4342
- name: Linting
4443
run: |
@@ -47,7 +46,7 @@ jobs:
4746
pylint service tests --max-line-length=127
4847
4948
- name: Run unit tests with PyTest
50-
run: pytest
49+
run: pytest --cov-report=xml
5150
env:
5251
DATABASE_URI: "redis://redis:6379/0"
5352

Dockerfile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
##################################################
2+
# Create production image
3+
##################################################
14
FROM python:3.11-slim
25

3-
# Create working folder and install dependencies
6+
# Set up the Python production environment
47
WORKDIR /app
5-
COPY pyproject.toml poetry.lock ./
6-
RUN python -m pip install --upgrade pip poetry && \
7-
poetry config virtualenvs.create false && \
8-
poetry install --without dev
8+
COPY Pipfile Pipfile.lock ./
9+
RUN python -m pip install --upgrade pip pipenv && \
10+
pipenv install --system --deploy
911

1012
# Copy the application contents
1113
COPY wsgi.py .
1214
COPY service/ ./service/
1315

14-
# Switch to a non-root user
15-
RUN useradd --uid 1000 flask && chown -R flask /app
16+
# Switch to a non-root user and set file ownership
17+
RUN useradd --uid 1001 flask && \
18+
chown -R flask /app
1619
USER flask
1720

1821
# Expose any ports the app is expecting in the environment
19-
ENV FLASK_APP=wsgi:app
22+
ENV FLASK_APP="wsgi:app"
2023
ENV PORT=8080
2124
EXPOSE $PORT
2225

Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ clean: ## Removes all dangling build cache
2727
.PHONY: venv
2828
venv: ## Create a Python virtual environment
2929
$(info Creating Python 3 virtual environment...)
30-
poetry config virtualenvs.in-project true
31-
poetry shell
30+
pipenv shell
3231

3332
.PHONY: install
3433
install: ## Install dependencies
3534
$(info Installing dependencies...)
36-
sudo poetry config virtualenvs.create false
37-
sudo poetry install
35+
sudo pipenv install --system --dev
3836

3937
.PHONY: lint
4038
lint: ## Run the linter
@@ -69,8 +67,8 @@ cluster: ## Create a K3D Kubernetes cluster with load balancer and registry
6967

7068
.PHONY: cluster-rm
7169
cluster-rm: ## Remove a K3D Kubernetes cluster
72-
$(info Removing Kubernetes cluster...)
73-
k3d cluster delete nyu-devops
70+
$(info Removing Kubernetes cluster $(CLUSTER)...)
71+
k3d cluster delete $(CLUSTER)
7472

7573
.PHONY: tekton
7674
tekton: ## Install Tekton
@@ -95,7 +93,7 @@ knative: ## Install Knative
9593
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.8.5/eventing-core.yaml
9694

9795
.PHONY: deploy
98-
depoy: ## Deploy the service on local Kubernetes
96+
deploy: ## Deploy the service on local Kubernetes
9997
$(info Deploying service locally...)
10098
kubectl apply -f k8s/
10199

@@ -117,6 +115,11 @@ build: ## Build all of the project Docker images
117115
$(info Building $(IMAGE) for $(PLATFORM)...)
118116
docker build --rm --pull --tag $(IMAGE) .
119117

118+
.PHONY: push
119+
push: ## Push the image to the container registry
120+
$(info Pushing $(IMAGE)...)
121+
docker push $(IMAGE)
122+
120123
.PHONY: buildx
121124
buildx: ## Build multi-platform image with buildx
122125
$(info Building multi-platform image $(IMAGE) for $(PLATFORM)...)

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+
redis = "~=5.0.0"
9+
flask-redis = "~=0.4.0"
10+
retry2 = "~=0.9.5"
11+
python-dotenv = "~=1.0.1"
12+
gunicorn = "~=23.0.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)