Skip to content

Commit

Permalink
Fix sample project incorporating comments from @mboes
Browse files Browse the repository at this point in the history
  • Loading branch information
smukherj1 committed Oct 26, 2018
1 parent 6b4454c commit 9ef4998
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
set -ex

IMAGE=$1
docker run -v $(pwd)/project:/workdir -w=/workdir --entrypoint="/bin/bash" ${IMAGE} run.sh
docker run -v $(pwd)/project:/workdir -p 8080:8080 -w=/workdir --entrypoint="/bin/bash" ${IMAGE} run.sh

1 change: 1 addition & 0 deletions project/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run --python_top=//:python-2.7.15
10 changes: 6 additions & 4 deletions project/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
py_binary(
name="app",
srcs=["app.py"],
deps = [
"@python-2.7.15//:python27Packages.python",
"@python2.7-Flask-1.0.2//:python27Packages.flask"
]
)

py_runtime(
name="python-2.7.15",
files=[],
interpreter="@python-2.7.15//:interpreter",
)
15 changes: 8 additions & 7 deletions project/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ nixpkgs_git_repository(

nixpkgs_package(
name= "python-2.7.15",
attribute_path= "python27Packages.python",
repositories = {"@nixpkgs": "nixpkgs"}
nix_file= "//:python.nix",
repositories = {"nixpkgs": "@nixpkgs//:default.nix"},
build_file_content= """
package(default_visibility = ["//visibility:public"])
filegroup(
name = "interpreter",
srcs = ["bin/python"],
)

nixpkgs_package(
name = "python2.7-Flask-1.0.2",
attribute_path= "python27Packages.flask",
repositories = { "@nixpkgs": "nixpkgs" }
"""
)

7 changes: 7 additions & 0 deletions project/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
@app.route('/')
def hello():
return "Hello World!"

if __name__ == '__main__':
app.run(
host='0.0.0.0',
port=8080,
debug=True
)
3 changes: 3 additions & 0 deletions project/python.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
with (import <nixpkgs> {});

python27.withPackages (pkgs: [pkgs.flask])
2 changes: 1 addition & 1 deletion project/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

set -ex

bazel build :app
bazel run :app

0 comments on commit 9ef4998

Please sign in to comment.