Skip to content

Commit

Permalink
Build and deploy platform-dev (#110)
Browse files Browse the repository at this point in the history
* Build and deploy platform-dev

* Remove asgi section
  • Loading branch information
ArmaanT authored Nov 21, 2021
1 parent dde2fac commit cd86669
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 7 deletions.
53 changes: 47 additions & 6 deletions .github/cdk/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
import { App } from "cdkactions";
import { LabsApplicationStack } from "@pennlabs/kraken";
import { App, Stack, Workflow } from "cdkactions";
import { DeployJob, DjangoProject, DockerPublishJob, ReactProject } from "@pennlabs/kraken";
import { Construct } from "constructs";

const app = new App();
new LabsApplicationStack(app, {
djangoProjectName: 'Platform',
dockerImageBaseName: 'platform',
});
class PlatformStack extends Stack {
public constructor(scope: Construct, name: string) {
super(scope, name);

const workflow = new Workflow(this, "build-and-deploy", {
name: "Build and Deploy",
on: "push",
});

const backend = new DjangoProject(workflow, {
projectName: "Platform",
path: "backend",
imageName: "platform-backend",
});

const publishPlatformDev = new DockerPublishJob(workflow, 'platform-dev', {
imageName: "platform-dev",
path: "backend",
dockerfile: "Dockerfile.dev"
},
{
needs: "django-check"
});

const frontend = new ReactProject(workflow, {
path: "frontend",
imageName: "platform-frontend",
});

new DeployJob(
workflow,
{},
{
needs: [
backend.publishJobId,
frontend.publishJobId,
publishPlatformDev.id,
],
}
);

}
}

new PlatformStack(app, 'platform')
app.synth();
29 changes: 28 additions & 1 deletion .github/workflows/cdkactions_build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated by cdkactions. Do not modify
# Generated as part of the 'application' stack.
# Generated as part of the 'platform' stack.
name: Build and Deploy
on: push
jobs:
Expand Down Expand Up @@ -74,6 +74,32 @@ jobs:
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/platform-backend:latest,pennlabs/platform-backend:${{ github.sha }}
needs: django-check
publish-platform-dev:
name: Publish platform-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-publish-platform-dev
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build/Publish
uses: docker/build-push-action@v2
with:
context: backend
file: backend/Dockerfile.dev
push: ${{ github.ref == 'refs/heads/master' }}
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/platform-dev:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/platform-dev:latest,pennlabs/platform-dev:${{ github.sha }}
needs: django-check
react-check:
name: React Check
runs-on: ubuntu-latest
Expand Down Expand Up @@ -174,3 +200,4 @@ jobs:
needs:
- publish-backend
- publish-frontend
- publish-platform-dev
18 changes: 18 additions & 0 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM pennlabs/django-base:9a59b9133a4c82d8391b282a3a39685d7ac6738d

LABEL maintainer="Penn Labs"

# Copy project dependencies
COPY Pipfile* /app/

# Install project dependencies
RUN pipenv install --system

# Copy project files
COPY . /app/

ENV DJANGO_SETTINGS_MODULE Platform.settings.production
ENV SECRET_KEY 'temporary key just to build the docker image'

# Collect static files
RUN python3 /app/manage.py collectstatic --noinput
15 changes: 15 additions & 0 deletions k8s/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ applications:
value: 80
- name: DOMAIN
value: platform.pennlabs.org
- name: dev
image: pennlabs/platform-dev
secret: platform-dev
port: 8080
ingress:
hosts:
- host: platform-dev.pennlabs.org
paths: ["/"]
extraEnv:
- name: DOMAIN
value: platform-dev.pennlabs.org
- name: DJANGO_SETTINGS_MODULE
value: Platform.settings.production
- name: DEV_LOGIN
value: True

cronjobs:
- name: clear-expired-tokens
Expand Down

0 comments on commit cd86669

Please sign in to comment.