Skip to content

Commit

Permalink
Add Dockerfiles and Helm.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ymh63600 committed Dec 24, 2023
1 parent 4aeac96 commit 0103302
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
13 changes: 13 additions & 0 deletions homework/ymh-webapp/backend-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.10

WORKDIR /app

COPY . /app

RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
EXPOSE 8000

ENV DATABASE_URL="postgresql://postgres:postgresmaster@ymh-postgresql-0/test"

CMD ["sh", "-c", "cd backend && uvicorn main:app --proxy-headers --host 0.0.0.0 --port 8000"]

13 changes: 13 additions & 0 deletions homework/ymh-webapp/frontend-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:14

WORKDIR /app

COPY . /app

RUN npm install
RUN npm install -D tailwindcss


EXPOSE 3000

CMD ["npm", "run", "start"]
37 changes: 37 additions & 0 deletions homework/ymh-webapp/helm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##Helm 裝 Postgres 我的作法

1. 在本地端裝postgres

```Shell
helm install ymh-postgresql-0 bitnami/postgresql --namespace ymh-webapp --set global.postgresql.auth.postgresPassword=postgresmaster --set global.postgresql.auth.password=postgresmaster --set global.postgresql.auth.username=postgres --set global.postgresql.auth.database=test
```

下面這兩個指令是要試連用的
```Shell
export POSTGRES_PASSWORD=$(kubectl get secret --namespace ymh-webapp ymh-postgres-postgresql -o jsonpath="{.data.postgres-password}" | base64 -d)
```

```Shell
kubectl run ymh-postgres-postgresql-client --rm --tty -i --restart='Never' --namespace ymh-webapp --image docker.io/bitnami/postgresql:16.1.0-debian-11-r9 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
--command -- psql --host ymh-postgres-postgresql -U postgres -d test -p 5432
```

2. 把本地端的檔案導出

```Shell
helm get values <release-name> > values.yaml
```

3. 確認檔案是對的、並且接上遠端的kubeconfig,然後刪除本地端的

```Shell
export KUBECONFIG=/Users/huangyoumei/poetry-demo/kubeconfig.yaml
helm uninstall <release-name>
```
4. 部署到遠端

```Shell
helm install <release-name> -f values.yaml <chart-name>
```


0 comments on commit 0103302

Please sign in to comment.