Spaces:
Sleeping
Sleeping
Commit
·
98dbe3e
1
Parent(s):
776aa28
updated
Browse files- Dockerfile +4 -9
- README.md +14 -1
- test_pg.py +4 -2
Dockerfile
CHANGED
@@ -1,18 +1,13 @@
|
|
1 |
FROM postgres
|
2 |
|
3 |
-
RUN useradd -m -u 1000
|
4 |
|
5 |
WORKDIR /app
|
6 |
|
7 |
USER root
|
8 |
|
9 |
-
RUN mkdir -p /
|
10 |
|
11 |
-
USER
|
12 |
|
13 |
-
|
14 |
-
RUN initdb -D /custom_pgdata
|
15 |
-
|
16 |
-
EXPOSE 5432
|
17 |
-
|
18 |
-
CMD ["postgres", "-h", "0.0.0.0", "-p", "8080"]
|
|
|
1 |
FROM postgres
|
2 |
|
3 |
+
# RUN useradd -m -u 1000 postgres
|
4 |
|
5 |
WORKDIR /app
|
6 |
|
7 |
USER root
|
8 |
|
9 |
+
RUN mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql/data
|
10 |
|
11 |
+
USER postgres
|
12 |
|
13 |
+
EXPOSE 5432
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -5,9 +5,22 @@ colorFrom: gray
|
|
5 |
colorTo: gray
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
-
app_port:
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
colorTo: gray
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
+
app_port: 5432
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
12 |
|
13 |
|
14 |
+
|
15 |
+
```bash
|
16 |
+
docker build -t pg_local .
|
17 |
+
```
|
18 |
+
|
19 |
+
```bash
|
20 |
+
docker run --name pg_local_container --env-file .env -p 5432:5432 pg_local
|
21 |
+
```
|
22 |
+
|
23 |
+
```bash
|
24 |
+
docker stop pg_local_container
|
25 |
+
docker rm pg_local_container
|
26 |
+
```
|
test_pg.py
CHANGED
@@ -5,8 +5,10 @@ import psycopg2
|
|
5 |
dotenv.load_dotenv()
|
6 |
|
7 |
conn = psycopg2.connect(
|
8 |
-
host="anuj-panthri-mlops-postgres.hf.space",
|
9 |
-
port=
|
|
|
|
|
10 |
user=os.environ["POSTGRES_USER"],
|
11 |
password=os.environ["POSTGRES_PASSWORD"],
|
12 |
database=os.environ["POSTGRES_DB"],
|
|
|
5 |
dotenv.load_dotenv()
|
6 |
|
7 |
conn = psycopg2.connect(
|
8 |
+
# host="anuj-panthri-mlops-postgres.hf.space",
|
9 |
+
# port=443,
|
10 |
+
host="localhost",
|
11 |
+
port=5432,
|
12 |
user=os.environ["POSTGRES_USER"],
|
13 |
password=os.environ["POSTGRES_PASSWORD"],
|
14 |
database=os.environ["POSTGRES_DB"],
|