Andrew Smith commited on
Commit
e359b32
·
1 Parent(s): 3570818

Update with instructions on running locally

Browse files
Files changed (6) hide show
  1. .gitignore +2 -1
  2. Dockerfile +6 -6
  3. README.md +18 -1
  4. image_search/main.py +2 -2
  5. supabase/config.toml +82 -0
  6. supabase/seed.sql +0 -0
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  __pycache__
2
  .vscode
3
- supabase/
 
 
1
  __pycache__
2
  .vscode
3
+ supabase/.branches
4
+ supabase/.temp
Dockerfile CHANGED
@@ -18,18 +18,18 @@ RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --n
18
  FROM python:3.11-slim-buster as runtime
19
 
20
  # Get secret DB_URL and output it to /test at buildtime
21
- RUN --mount=type=secret,id=DB_URL,mode=0444,required=true \
22
- cat /run/secrets/DB_URL > /test
23
 
24
  ENV VIRTUAL_ENV=/app/.venv \
25
  PATH="/app/.venv/bin:$PATH"
26
 
27
  COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
28
 
29
- WORKDIR /app
 
 
30
 
31
- COPY image_search /app/image_search
32
- COPY static /app/static
33
- COPY images /app/images
34
 
35
  CMD ["uvicorn", "image_search.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
18
  FROM python:3.11-slim-buster as runtime
19
 
20
  # Get secret DB_URL and output it to /test at buildtime
21
+ # RUN --mount=type=secret,id=DB_URL,mode=0444,required=true \
22
+ # cat /run/secrets/DB_URL > /test
23
 
24
  ENV VIRTUAL_ENV=/app/.venv \
25
  PATH="/app/.venv/bin:$PATH"
26
 
27
  COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
28
 
29
+ COPY image_search /image_search
30
+ COPY static /static
31
+ COPY images /images
32
 
33
+ RUN ls -la ${VIRTUAL_ENV}
 
 
34
 
35
  CMD ["uvicorn", "image_search.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -8,4 +8,21 @@ pinned: false
8
  license: apache-2.0
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  license: apache-2.0
9
  ---
10
 
11
+ You can run this space locally by clicking on the three dots menu next to the Settings option. Then click on Run with Docker.
12
+
13
+ ### Getting started
14
+
15
+ Firstly lets seed our database using the `/seed` endpoint:
16
+
17
+ ```
18
+ http://localhost:7860/seed
19
+ ```
20
+
21
+ Now you can do your first search using the `/search` endpoint:
22
+
23
+ ```
24
+ http://localhost:7860/search?query=grapes
25
+ ```
26
+
27
+ or you can use the UI by visiting `http://localhost:7860/`
28
+
image_search/main.py CHANGED
@@ -86,8 +86,8 @@ def search(query: Union[str, None] = None):
86
  return {"result": result, "query": query}
87
 
88
 
89
- # app.mount("/images", StaticFiles(directory="images"), name="images")
90
- # app.mount("/", StaticFiles(directory="static", html=True), name="static")
91
 
92
 
93
  @app.get("/")
 
86
  return {"result": result, "query": query}
87
 
88
 
89
+ app.mount("/images", StaticFiles(directory="images"), name="images")
90
+ app.mount("/", StaticFiles(directory="static", html=True), name="static")
91
 
92
 
93
  @app.get("/")
supabase/config.toml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A string used to distinguish different Supabase projects on the same host. Defaults to the working
2
+ # directory name when running `supabase init`.
3
+ project_id = "image-search"
4
+
5
+ [api]
6
+ # Port to use for the API URL.
7
+ port = 54321
8
+ # Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
9
+ # endpoints. public and storage are always included.
10
+ schemas = ["public", "storage", "graphql_public"]
11
+ # Extra schemas to add to the search_path of every request. public is always included.
12
+ extra_search_path = ["public", "extensions"]
13
+ # The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
14
+ # for accidental or malicious requests.
15
+ max_rows = 1000
16
+
17
+ [db]
18
+ # Port to use for the local database URL.
19
+ port = 54322
20
+ # The database major version to use. This has to be the same as your remote database's. Run `SHOW
21
+ # server_version;` on the remote database to check.
22
+ major_version = 15
23
+
24
+ [studio]
25
+ # Port to use for Supabase Studio.
26
+ port = 54323
27
+
28
+ # Email testing server. Emails sent with the local dev setup are not actually sent - rather, they
29
+ # are monitored, and you can view the emails that would have been sent from the web interface.
30
+ [inbucket]
31
+ # Port to use for the email testing server web interface.
32
+ port = 54324
33
+ smtp_port = 54325
34
+ pop3_port = 54326
35
+
36
+ [storage]
37
+ # The maximum file size allowed (e.g. "5MB", "500KB").
38
+ file_size_limit = "50MiB"
39
+
40
+ [auth]
41
+ # The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
42
+ # in emails.
43
+ site_url = "http://localhost:3000"
44
+ # A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
45
+ additional_redirect_urls = ["https://localhost:3000"]
46
+ # How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one
47
+ # week).
48
+ jwt_expiry = 3600
49
+ # Allow/disallow new user signups to your project.
50
+ enable_signup = true
51
+
52
+ [auth.email]
53
+ # Allow/disallow new user signups via email to your project.
54
+ enable_signup = true
55
+ # If enabled, a user will be required to confirm any email change on both the old, and new email
56
+ # addresses. If disabled, only the new email is required to confirm.
57
+ double_confirm_changes = true
58
+ # If enabled, users need to confirm their email address before signing in.
59
+ enable_confirmations = false
60
+
61
+ # Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`,
62
+ # `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `twitch`,
63
+ # `twitter`, `slack`, `spotify`, `workos`, `zoom`.
64
+ [auth.external.apple]
65
+ enabled = false
66
+ client_id = ""
67
+ secret = ""
68
+ # Overrides the default auth redirectUrl.
69
+ redirect_uri = ""
70
+ # Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure,
71
+ # or any other third-party OIDC providers.
72
+ url = ""
73
+
74
+ [analytics]
75
+ enabled = false
76
+ port = 54327
77
+ vector_port = 54328
78
+ # Setup BigQuery project to enable log viewer on local development stack.
79
+ # See: https://supabase.com/docs/guides/getting-started/local-development#enabling-local-logging
80
+ gcp_project_id = ""
81
+ gcp_project_number = ""
82
+ gcp_jwt_path = "supabase/gcloud.json"
supabase/seed.sql ADDED
File without changes