create kubernetes deployment

This commit is contained in:
Cadey Ratio 2020-07-14 17:56:14 -04:00
parent 82cf960ccd
commit a12205aa1b
5 changed files with 36 additions and 38 deletions

View File

@ -1,16 +1,35 @@
name: "Nix" name: "Nix"
on: on:
push: push:
branches:
- master
jobs: jobs:
tests: docker-build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: cachix/install-nix-action@v6 - uses: cachix/install-nix-action@v6
- uses: cachix/cachix-action@v3 - uses: cachix/cachix-action@v3
with: with:
name: xe name: xe
- run: | signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
nix-build docker.nix authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
docker load -i result - run: |
docker tag xena/christinewebsite:latest xena/christinewebsite:$(echo $GITHUB_SHA | head -c7) nix-build docker.nix
docker load -i result
docker tag xena/christinewebsite:latest xena/christinewebsite:$GITHUB_SHA
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
docker push xena/christinewebsite
env:
DOCKER_USERNAME: "xena"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
release:
runs-on: ubuntu-latest
needs: docker-build
if: github.ref == 'refs/heads/master'
steps:
- uses: cachix/install-nix-action@v6
- name: deploy
run: ./scripts/release.sh
env:
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}

View File

@ -1,20 +0,0 @@
FROM xena/go:1.14 AS build
ENV GOPROXY https://cache.greedo.xeserv.us
COPY . /site
WORKDIR /site
RUN CGO_ENABLED=0 go test -v ./...
RUN CGO_ENABLED=0 GOBIN=/root go install -v ./cmd/site
FROM xena/alpine
EXPOSE 5000
WORKDIR /site
COPY --from=build /root/site .
COPY ./static /site/static
COPY ./templates /site/templates
COPY ./blog /site/blog
COPY ./talks /site/talks
COPY ./gallery /site/gallery
COPY ./css /site/css
COPY ./signalboost.dhall /site/signalboost.dhall
HEALTHCHECK CMD wget --spider http://127.0.0.1:5000/.within/health || exit 1
CMD ./site

View File

@ -1,6 +0,0 @@
#!/bin/sh
set -e
docker build -t xena/site .
exec docker run --rm -itp 5030:5000 -e PORT=5000 xena/site

5
scripts/release.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env nix-shell
#! nix-shell -p doctl -p kubectl -i bash
doctl kubernetes cluster kubeconfig save kubermemes
dhall-to-yaml-ng < ./site.dhall | kubectl apply -n apps -f -
kubectl rollout status -n apps deployment/christinewebsite

View File

@ -10,12 +10,12 @@ let image = "xena/christinewebsite:${tag}"
let vars let vars
: List kubernetes.EnvVar.Type : List kubernetes.EnvVar.Type
= [ kubernetes.EnvVar::{ name = "PORT", value = Some "5000" } ] = [ kubernetes.EnvVar::{ name = "PORT", value = Some "3030" } ]
in kms.app.make in kms.app.make
kms.app.Config::{ kms.app.Config::{
, name = "christinewebsite" , name = "christinewebsite"
, appPort = 5000 , appPort = 3030
, image = image , image = image
, domain = "christine.website" , domain = "christine.website"
, leIssuer = "prod" , leIssuer = "prod"