-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
756565f
commit 95f9b48
Showing
3 changed files
with
73 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
load("@rules_python//python:defs.bzl", "py_binary") | ||
load("//tools/build_rules:cross_platform_image.bzl", "cross_platform_image") | ||
load("//tools/build_rules:py_layer.bzl", "py_oci_image") | ||
|
||
py_binary( | ||
name = "binary", | ||
srcs = ["app.py"], | ||
imports = [".."], | ||
main = "app.py", | ||
visibility = ["//:__subpackages__"], | ||
deps = ["//skeleton:config_py"], | ||
) | ||
|
||
py_oci_image( | ||
name = "base_image", | ||
base = "@python3_image", | ||
binaries = [ | ||
"//scripts:wait_for_postgres", | ||
":binary", | ||
], | ||
cmd = [ | ||
"/" + package_name() + "/binary", | ||
], | ||
entrypoint = [ | ||
"/scripts/wait_for_postgres", | ||
], | ||
env = { | ||
"FLASK_APP": "app.py", | ||
"FLASK_DEBUG": "True", | ||
"API_PORT": "5000", | ||
"FRONTEND_PROTOCOL": "http", | ||
"FRONTEND_HOST": "frontend", | ||
"FRONTEND_PORT": "5001", | ||
"DB_HOST": "pg", | ||
"DB_USERNAME": "admin", | ||
"DB_PASSWORD": "development", | ||
"DATABASE_NAME": "api_development", | ||
"FITBIT_CLIENT_ID": "testing", | ||
"FITBIT_CLIENT_SECRET": "testing", | ||
"FITBIT_VERIFICATION_CODE": "testing", | ||
"FLASK_SECRET_KEY": "testing", | ||
}, | ||
tags = ["manual"], | ||
) | ||
|
||
# $ bazel run //skeleton/worker:image_tarball | ||
# $ docker run --rm shaldengeki/skeleton-worker:latest | ||
cross_platform_image( | ||
name = "image", | ||
image = ":base_image", | ||
repo_tags = ["shaldengeki/skeleton-worker:latest"], | ||
repository = "docker.io/shaldengeki/skeleton-worker", | ||
visibility = ["//skeleton/worker:__subpackages__"], | ||
) |
Empty file.
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,19 @@ | ||
import time | ||
|
||
from fitbit_challenges.config import app, db | ||
|
||
max_delay = 10 | ||
|
||
|
||
def main() -> int: | ||
with app.app_context(): | ||
while True: | ||
start = time.time() | ||
# Do work here. | ||
delay = (start + max_delay) - time.time() | ||
if delay > 0: | ||
time.sleep(delay) | ||
|
||
|
||
if __name__ == "__main__": | ||
raise SystemExit(main()) |