diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml deleted file mode 100644 index 7e5c2878..00000000 --- a/.github/workflows/manual.yml +++ /dev/null @@ -1,46 +0,0 @@ -# Workflow to ensure whenever a Github PR is submitted, -# a JIRA ticket gets created automatically. -name: Manual Workflow - -# Controls when the action will run. -on: - # Triggers the workflow on pull request events but only for the master branch - pull_request_target: - types: [opened, reopened] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - test-transition-issue: - name: Convert Github Issue to Jira Issue - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - - name: Login - uses: atlassian/gajira-login@master - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - - - name: Create NEW JIRA ticket - id: create - uses: atlassian/gajira-create@v2.0.1 - with: - project: CONUPDATE - issuetype: Task - summary: | - Github PR [Assign the ND component] | Repo: ${{ github.repository }} | PR# ${{github.event.number}} - description: | - Repo link: https://github.com/${{ github.repository }} - PR no. ${{ github.event.pull_request.number }} - PR title: ${{ github.event.pull_request.title }} - PR description: ${{ github.event.pull_request.description }} - In addition, please resolve other issues, if any. - fields: '{"components": [{"name":"Github PR"}], "customfield_16449":"https://classroom.udacity.com/", "customfield_16450":"Resolve the PR", "priority":{"id": "4"}}' - - - name: Log created issue - run: echo "Issue ${{ steps.create.outputs.issue }} was created" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..288e36af --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/buildspec.yaml b/buildspec.yaml new file mode 100644 index 00000000..5aaa1c06 --- /dev/null +++ b/buildspec.yaml @@ -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 diff --git a/deployment-local/service.yaml b/deployment-local/service.yaml new file mode 100644 index 00000000..887f5a8c --- /dev/null +++ b/deployment-local/service.yaml @@ -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 \ No newline at end of file diff --git a/deployment/configmap.yaml b/deployment/configmap.yaml index 7dcae113..589bfb23 100644 --- a/deployment/configmap.yaml +++ b/deployment/configmap.yaml @@ -1,17 +1,9 @@ apiVersion: v1 kind: ConfigMap metadata: - name: + name: dbconfigmap data: - DB_NAME: - DB_USER: - DB_HOST: - DB_PORT: ---- -apiVersion: v1 -kind: Secret -metadata: - name: -type: Opaque -data: - : \ No newline at end of file + DB_NAME: "mydatabase" + DB_USERNAME: "myuser" + DB_HOST: "postgresql-service" + DB_PORT: "5432" \ No newline at end of file diff --git a/deployment/coworking.yaml b/deployment/coworking.yaml index cf86a612..e18c353b 100644 --- a/deployment/coworking.yaml +++ b/deployment/coworking.yaml @@ -30,7 +30,7 @@ spec: spec: containers: - name: coworking - image: + image: 497971030638.dkr.ecr.us-east-1.amazonaws.com/coworking:0.0.2 imagePullPolicy: IfNotPresent livenessProbe: httpGet: @@ -45,12 +45,34 @@ spec: initialDelaySeconds: 5 timeoutSeconds: 5 envFrom: + - secretRef: + name: dbsecret - configMapRef: - name: + 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: - key: + name: dbsecret + key: DB_PASSWORD restartPolicy: Always \ No newline at end of file diff --git a/deployment/secrets.yaml b/deployment/secrets.yaml new file mode 100644 index 00000000..043900f4 --- /dev/null +++ b/deployment/secrets.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: dbsecret +type: Opaque +data: + DB_PASSWORD: bXlwYXNzd29yZA== \ No newline at end of file diff --git a/postgresql-deployment.yaml b/postgresql-deployment.yaml new file mode 100644 index 00000000..ca9b7df2 --- /dev/null +++ b/postgresql-deployment.yaml @@ -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 \ No newline at end of file diff --git a/postgresql-service.yaml b/postgresql-service.yaml new file mode 100644 index 00000000..733e368f --- /dev/null +++ b/postgresql-service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgresql-service +spec: + ports: + - port: 5432 + targetPort: 5432 + selector: + app: postgresql \ No newline at end of file diff --git a/pv.yaml b/pv.yaml new file mode 100644 index 00000000..31facea9 --- /dev/null +++ b/pv.yaml @@ -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" \ No newline at end of file diff --git a/pvc.yaml b/pvc.yaml new file mode 100644 index 00000000..dc1e507a --- /dev/null +++ b/pvc.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: postgresql-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi \ No newline at end of file