Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for rebuild #19

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/workflows/manual.yml

This file was deleted.

16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Python Python 3.10 as the base image
FROM public.ecr.aws/docker/library/python:3.10-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the current directory contents to the container at /app
COPY ./analytics/ /app

RUN apt update -y
RUN apt install build-essential libpq-dev -y
RUN pip install --upgrade pip setuptools wheel
RUN pip install --upgrade pip && pip install -r requirements.txt

# Run the application when the container starts
CMD python app.py
18 changes: 18 additions & 0 deletions buildspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.2

phases:
pre_build:
commands:
- echo Logging into ECR
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
build:
commands:
- echo Starting build at `date`
- echo Building the Docker image...
- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
commands:
- echo Completed build at `date`
- echo Pushing the Docker image...
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
14 changes: 14 additions & 0 deletions deployment-local/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: analyticslb
labels:
app: analytics-api
spec:
type: LoadBalancer
selector:
app: analytics-api
ports:
- protocol: TCP
port: 80
targetPort: 5153
18 changes: 5 additions & 13 deletions deployment/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: <NAME OF THE ConfigMap>
name: dbconfigmap
data:
DB_NAME: <ENTER YOUR DB NAME HERE>
DB_USER: <ENTER YOUR USER NAME HERE>
DB_HOST: <ENTER YOUR DB HOST HERE>
DB_PORT: <ENTER YOUR DB PORT HERE>
---
apiVersion: v1
kind: Secret
metadata:
name: <NAME OF THE Secret>
type: Opaque
data:
<THE KEY FROM Secret WHICH has THE ENCODED PASSWORD>: <OUTPUT OF `echo -n 'the password' | base64`>
DB_NAME: "mydatabase"
DB_USERNAME: "myuser"
DB_HOST: "postgresql-service"
DB_PORT: "5432"
30 changes: 26 additions & 4 deletions deployment/coworking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
spec:
containers:
- name: coworking
image: <DOCKER_IMAGE_URI_FROM_ECR>
image: 497971030638.dkr.ecr.us-east-1.amazonaws.com/coworking:0.0.2
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand All @@ -45,12 +45,34 @@ spec:
initialDelaySeconds: 5
timeoutSeconds: 5
envFrom:
- secretRef:
name: dbsecret
- configMapRef:
name: <NAME OF THE ConfigMap>
name: dbconfigmap
env:
- name: DB_USERNAME
valueFrom:
configMapKeyRef:
name: dbconfigmap
key: DB_USERNAME
- name: DB_NAME
valueFrom:
configMapKeyRef:
name: dbconfigmap
key: DB_NAME
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: dbconfigmap
key: DB_HOST
- name: DB_PORT
valueFrom:
configMapKeyRef:
name: dbconfigmap
key: DB_PORT
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: <NAME OF THE Secret>
key: <THE KEY FROM Secret WHICH has THE ENCODED PASSWORD>
name: dbsecret
key: DB_PASSWORD
restartPolicy: Always
7 changes: 7 additions & 0 deletions deployment/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: dbsecret
type: Opaque
data:
DB_PASSWORD: bXlwYXNzd29yZA==
32 changes: 32 additions & 0 deletions postgresql-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresql
spec:
selector:
matchLabels:
app: postgresql
template:
metadata:
labels:
app: postgresql
spec:
containers:
- name: postgresql
image: postgres:latest
env:
- name: POSTGRES_DB
value: mydatabase
- name: POSTGRES_USER
value: myuser
- name: POSTGRES_PASSWORD
value: mypassword
ports:
- containerPort: 5432
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgresql-storage
volumes:
- name: postgresql-storage
persistentVolumeClaim:
claimName: postgresql-pvc
10 changes: 10 additions & 0 deletions postgresql-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: postgresql-service
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: postgresql
13 changes: 13 additions & 0 deletions pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-manual-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: gp2
hostPath:
path: "/mnt/data"
10 changes: 10 additions & 0 deletions pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgresql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi