Move to automated github builds
This commit is contained in:
parent
fe09b5bfe3
commit
376ea09083
4 changed files with 122 additions and 0 deletions
53
.github/workflows/build.yml
vendored
Normal file
53
.github/workflows/build.yml
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Build application
|
||||
run: |
|
||||
docker build . -f Dockerfile -t "adriano_fyi:${GITHUB_SHA}"
|
||||
mkdir out
|
||||
docker save "adriano_fyi:${GITHUB_SHA}" -o "out/adriano_fyi-${GITHUB_SHA}.tar"
|
||||
- name: S3 Sync
|
||||
uses: jakejarvis/s3-sync-action@v0.5.1
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: "VRHJL00O2NRFX0SG5PNH"
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.LINODE_SECRET_ACCESS_KEY }}
|
||||
AWS_S3_BUCKET: "adriano-fyi-static-site"
|
||||
AWS_REGION: "us-east-1"
|
||||
AWS_S3_ENDPOINT: "https://us-east-1.linodeobjects.com"
|
||||
SOURCE_DIR: "out"
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Tailscale Login
|
||||
uses: tailscale/github-action@main
|
||||
with:
|
||||
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
|
||||
version: 1.32.1
|
||||
env:
|
||||
ADDITIONAL_ARGS: "--accept-dns"
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Deploy nomad job
|
||||
run: |
|
||||
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
|
||||
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
|
||||
sudo apt-get update && sudo apt-get install nomad
|
||||
tailscale status
|
||||
nomad job run -var version=${GITHUB_SHA} job.nomad.hcl
|
||||
env:
|
||||
NOMAD_ADDR: http://cluster-0:4646
|
||||
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1,3 @@
|
|||
public
|
||||
out
|
||||
tags
|
||||
|
|
|
|||
19
Dockerfile
Normal file
19
Dockerfile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FROM klakegg/hugo:ext
|
||||
|
||||
RUN apt-get update && apt-get install busybox
|
||||
|
||||
# Create a non-root user to own the files and run our server
|
||||
RUN adduser --disabled-login static
|
||||
|
||||
# Copy the static website
|
||||
# Use the .dockerignore file to control what ends up inside the image!
|
||||
COPY . /home/static
|
||||
|
||||
WORKDIR /home/static
|
||||
RUN hugo -d public
|
||||
|
||||
RUN chown -R static:static /home/static
|
||||
USER static
|
||||
|
||||
# Run BusyBox httpd
|
||||
ENTRYPOINT ["busybox", "httpd", "-f", "-v", "-p", "3000", "-h", "public"]
|
||||
48
job.nomad.hcl
Normal file
48
job.nomad.hcl
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
variable "version" {
|
||||
type = string
|
||||
}
|
||||
|
||||
job "adriano.fyi" {
|
||||
datacenters = ["dc1"]
|
||||
namespace = "default"
|
||||
|
||||
group "task" {
|
||||
network {
|
||||
port "http" {
|
||||
to = 3000
|
||||
host_network = "private"
|
||||
}
|
||||
}
|
||||
|
||||
task "webserver" {
|
||||
driver = "docker"
|
||||
|
||||
artifact {
|
||||
source = "s3://us-east-1.linodeobjects.com/adriano-fyi-static-site/adriano_fyi-${var.version}.tar"
|
||||
options {
|
||||
aws_access_key_id = "U8GPO4T1HQ0S5FZO8WV9"
|
||||
aws_access_key_secret = "a5dlaGsstjR9lRJZHANXqR3jdW9i2dRU1BjQCC6Y"
|
||||
# Leave the archive in tar format
|
||||
archive = false
|
||||
}
|
||||
}
|
||||
|
||||
config {
|
||||
load = "adriano_fyi-${var.version}.tar"
|
||||
image = "adriano_fyi:${var.version}"
|
||||
ports = ["http"]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 1024
|
||||
memory = 1024
|
||||
}
|
||||
|
||||
service {
|
||||
port = "http"
|
||||
name = "adriano-fyi"
|
||||
provider = "nomad"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue