-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nyu-devops/updates-sp24
Updates for Spring 2024 Semester
- Loading branch information
Showing
28 changed files
with
1,731 additions
and
359 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
FROM rofrano/nyu-devops-base:fa23 | ||
# Image for a Python 3 development environment | ||
FROM python:3.11-slim | ||
|
||
# Add Python package requiremnets to the dev environment | ||
# Add any tools that are needed beyond Python 3.9 | ||
RUN apt-get update && \ | ||
apt-get install -y sudo vim make git zip tree curl wget jq && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean -y | ||
|
||
# Create a user for development | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
# Create the user with passwordless sudo privileges | ||
RUN groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \ | ||
&& usermod -aG sudo $USERNAME \ | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
# Install poetry stand alone | ||
# RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
# Set up the Python development environment | ||
WORKDIR /app | ||
COPY requirements.txt . | ||
RUN sudo pip install -U pip wheel && \ | ||
sudo pip install -r requirements.txt | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN python -m pip install -U pip poetry && \ | ||
poetry config virtualenvs.create false && \ | ||
poetry install | ||
|
||
ENV PORT 8000 | ||
EXPOSE $PORT | ||
|
||
# Enable color terminal for docker exec bash | ||
ENV TERM=xterm-256color | ||
|
||
# Become a regular user | ||
USER $USERNAME |
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 |
---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |
services: | ||
# Label used to access the service container | ||
postgres: | ||
image: postgres | ||
image: postgres:15-alpine | ||
env: | ||
POSTGRES_PASSWORD: pgs3cr3t | ||
POSTGRES_DB: testdb | ||
|
@@ -40,23 +40,19 @@ jobs: | |
# Steps for the build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install libraries for PostgreSQL | ||
run: | | ||
apt-get update | ||
apt-get install -y gcc libpq-dev | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
python -m pip install -U pip poetry | ||
poetry config virtualenvs.create false | ||
poetry install | ||
- name: Linting | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# check for omplexity. The GitHub editor is 127 chars wide | ||
# check for complexity. The GitHub editor is 127 chars wide | ||
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics | ||
# Run pylint on the service | ||
pylint service tests --max-line-length=127 | ||
|
@@ -66,7 +62,7 @@ jobs: | |
export FLASK_APP=service:app | ||
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings | ||
env: | ||
DATABASE_URI: "postgresql://postgres:pgs3cr3t@postgres:5432/testdb" | ||
DATABASE_URI: "postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/testdb" | ||
|
||
- name: Upload code coverage | ||
uses: codecov/[email protected] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
FROM python:3.11-slim | ||
|
||
# Establish a working folder | ||
WORKDIR /app | ||
|
||
# Establish dependencies | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN python -m pip install poetry && \ | ||
poetry config virtualenvs.create false && \ | ||
poetry install --without dev | ||
|
||
# Copy source files last because they change the most | ||
COPY wsgi.py . | ||
COPY service ./service | ||
|
||
# Become non-root user | ||
RUN useradd -m -r service && \ | ||
chown -R service:service /app | ||
USER service | ||
|
||
# Run the service on port 8080 | ||
EXPOSE 8080 | ||
CMD ["gunicorn", "wsgi:app", "--bind", "0.0.0.0:8080"] |
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 |
---|---|---|
@@ -1 +1 @@ | ||
web: gunicorn --bind 0.0.0.0:$PORT --log-level=info service:app | ||
web: gunicorn --log-file=- --workers=1 --bind=0.0.0.0:$PORT wsgi:app |
Oops, something went wrong.