Skip to content

Commit

Permalink
Merge pull request #12 from UpMortem/dockerize-py
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbandi authored Jan 27, 2023
2 parents 35e4414 + a372d44 commit 1c3ca35
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 5,130 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ tslint.json
.env
Dockerfile
dev-env-setup/*
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ OPENAI_API_KEY=openai-api-key
# SERVER
FLASK_APP=src/index.py
FLASK_RUN_HOST=localhost
FLASK_RUN_PORT=3000
FLASK_RUN_PORT=8080
19 changes: 12 additions & 7 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
# - run: npm test
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
FROM node:19.4.0-bullseye-slim

COPY ./* /app/
FROM python:3.10-slim
ENV PYTHONUNBUFFERED True

WORKDIR /app

RUN npm install
RUN npm run build
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY ./src ./src

CMD ["npm", "start"]
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 index:flask_app --chdir /app/src

EXPOSE 8080
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# slack-bot

## Setup
## Setup for dev

- Set variables in .env file
- Have venv installed
- To enable the virtual environment run `source venv/bin/activate` on Linux/MacOS and `venv\Scripts\activate` on Windows
- Run `pip install -r "requirements.txt"` to install dependencies
- Run `flask --debug run` to start the dev server
- Have venv installed `python3 -m pip install virtualenv` and create a venv at the root of your project using `python3 -m virtualenv -p python3 myvenv`
- To enable the virtual environment run `source myvenv/bin/activate` on Linux/MacOS and `myvenv\Scripts\activate` on Windows - this opens up a terminal into the virtual environment.
- verify your python is isolated by typing `where python` in the above terminal
- Run `pip install -r "requirements.txt"` to install dependencies in the same terminal
- Run `flask --debug run` to start the dev server in the same terminal

If you use the --debug flag when running flask, the application will rebuild whenever the source code changes.

## release

- Setup a new release tag in github for the revision you want to release
- Got to google cloud console
- Click on the instance you want to release to (or create new deployment through cloud build)
- Click on `EDIT & DEPLOY NEW REVISION`
- Update the tag version in the `Container image URL` field.
- Scroll down and click deploy
2 changes: 0 additions & 2 deletions cloudbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ options:
logging: CLOUD_LOGGING_ONLY
substitutions:
_GCR_HOSTNAME: us.gcr.io
_PLATFORM: managed
_SERVICE_NAME: haly-master
_DEPLOY_REGION: us-central1
tags:
- haly-master
42 changes: 0 additions & 42 deletions developer_cloudbuild.yml

This file was deleted.

Loading

0 comments on commit 1c3ca35

Please sign in to comment.