-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bare flask + container skeleton #4
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: run tests | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: [3.8, 3.9] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
- name: Install pipenv and any other packages | ||
run: | | ||
python -m pip install pipenv | ||
pipenv install --dev | ||
- name: Run pytest | ||
run: pipenv run pytest service | ||
- name: Lint with flake8 | ||
run: pipenv run flake8 service |
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
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,15 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
ansible-bender = "*" | ||
autopep8 = "*" | ||
flake8 = "*" | ||
pylint = "*" | ||
pytest = "*" | ||
selinux = "*" | ||
|
||
[packages] | ||
rtls = {editable = true, path = "./service"} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: rtls build | ||
hosts: all | ||
vars: | ||
www_root: '/var/www/rtls/service' | ||
ansible_bender: | ||
base_image: 'registry.fedoraproject.org/fedora:latest' | ||
cache_tasks: False | ||
layering: False | ||
target_image: | ||
name: rtls | ||
environment: | ||
PIPENV_VENV_IN_PROJECT: 'True' | ||
entrypoint: "{{ www_root }}/service_run.sh" | ||
working_dir: "{{ www_root }}" | ||
tasks: | ||
- name: Setup the base | ||
include_role: | ||
name: base | ||
|
||
- name: Setup the app | ||
include_role: | ||
name: app |
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,38 @@ | ||
--- | ||
|
||
- name: Setting up the app directory | ||
file: | ||
path: "{{ www_root }}" | ||
state: directory | ||
|
||
- name: Copy app code | ||
copy: | ||
src: "{{ playbook_dir }}/service" | ||
dest: "{{ app_root }}" | ||
|
||
- name: Copy python packaging files | ||
copy: | ||
src: "{{ item }}" | ||
dest: "{{ app_root }}" | ||
loop: | ||
- "{{ playbook_dir }}/service/setup.py" | ||
- "{{ playbook_dir }}/service/requirements.txt" | ||
|
||
- name: Copy Pipenv files | ||
copy: | ||
src: "{{ item }}" | ||
dest: "{{ www_root }}" | ||
mode: preserve | ||
loop: | ||
- "{{ playbook_dir }}/Pipfile" | ||
|
||
- name: Setup venv | ||
shell: | ||
cmd: "pipenv update" | ||
chdir: "{{ app_root }}" | ||
|
||
- name: Copy files | ||
template: | ||
src: templates/service_run.j2 | ||
dest: "{{ app_root }}/service_run.sh" | ||
mode: 'o+x' |
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,9 @@ | ||
#! /bin/bash | ||
|
||
source {{ www_root }}/.venv/bin/activate | ||
cd {{ www_root }} | ||
nginx | ||
# Timeout value is in seconds | ||
gunicorn wsgi:app \ | ||
--bind 127.0.0.1:8000 \ | ||
--timeout 300 |
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,3 @@ | ||
--- | ||
|
||
app_root: '{{ www_root }}' |
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,4 @@ | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; |
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,9 @@ | ||
server { | ||
listen 80; | ||
server_name server_domain_or_IP; | ||
|
||
location / { | ||
include proxy_params; | ||
proxy_pass http://127.0.0.1:8000; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should remove this and instead use github actions similar to https://github.com/release-depot/flask-container-scaffold/blob/main/.github/workflows/test.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, travis has not been great recently, and I think actions are now the preferred method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the idea as well. I tried to update this PR with a first attempt at a github action, though I wouldn't be surprised if it takes a couple iterations to get it working!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you have looks fine, we can always do a rev to fix CI if needed. Are you wanting to leave travis file in until we see if the new actions work correctly? If so, we could easily test the action with the next patch removing travis (the other alternative would be to temporarily not limit push action tests to be on main (well, I guess this is still using 'master'), and once you see the action work on your own branch, you will know you can limit it to just main for the patch).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable to me! And yes, the repo was created a couple of years ago so it still uses master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok - maybe as a next step before adding more working code, we should move this to the newer 'main' standard? We need to start shifting everything anyway. I am approving this, looks good!