Skip to content

Commit

Permalink
add resources for deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellcassius committed Oct 4, 2023
1 parent 04ee799 commit 61e31fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on:
push:
branches:
- "main"
pull_request:
- "devops"

env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER_NAME }}
ENV_PROD: ${{ secrets.ENV_PROD }}
GKE_ZONE: us-central1-c
IMAGE: api-cct
MY_ENV: production
Expand Down Expand Up @@ -53,6 +54,10 @@ jobs:
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}

- name: Mount env
run: |-
echo $ENV_PROD > .env
- name: Build Docker image
run: |-
docker build \
Expand All @@ -66,15 +71,13 @@ jobs:
- name: Set up Kustomize
run: |-
cd ./.kubernetes/prod
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
- name: Set up Kustomize
run: |-
envsubst < kustomization.yaml.tmpl > kustomization.yaml
- name: Deploy
run: |-
cd ./.kubernetes/prod
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE_API:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
./kustomize build . | kubectl apply -n cct -f -
kubectl get services -n cct -o wide
12 changes: 1 addition & 11 deletions .kubernetes/prod/k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@ spec:
spec:
containers:
- name: cct-api
image: gcr.io/rj-smtr/api-cct:1.0.1-rc.1
command:
[
"sh",
"-c",
"sed",
"-i",
"'14s/.*/DATABASE_PASWORD=${DATABASE_PASSWORD}/'",
"-f",
"/usr/src/app/.env",
]
image: gcr.io/PROJECT_ID/IMAGE_APP:TAG
ports:
- containerPort: 3000
# resources:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN sed -i 's/\r//g' /opt/wait-for-it.sh
RUN sed -i 's/\r//g' /opt/startup.dev.sh

WORKDIR /usr/src/app
RUN cp env-deploy .env
RUN cp .env .env
RUN npm run build

CMD ["/opt/startup.dev.sh"]

0 comments on commit 61e31fe

Please sign in to comment.