Compare commits

...

1 commit
main ... master

Author SHA1 Message Date
Adriano Caloiaro
fb4a99a75d
Move to automated github builds 2023-01-07 08:52:53 -08:00
4 changed files with 121 additions and 0 deletions

53
.github/workflows/build.yml vendored Normal file
View 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: "D1NFLA7HVIDF1MOHI2RT"
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 }}

1
.gitignore vendored
View file

@ -1 +1,2 @@
public
out

19
Dockerfile Normal file
View 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
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
View 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-${GITHUB_SHA}.tar"
options {
aws_access_key_id = "LPG6GTPT3UY81QJ7Q6H2"
aws_access_key_secret = "C0K4XfDNDDQQM7xcph5hy33QCYtZflpiEVAIeKJP"
# Leave the archive in tar format
archive = false
}
}
config {
load = "adriano_fyi-${var.version}.tar"
image = "adriano_fyi:${var.version}"
ports = ["outside_careers"]
}
resources {
cpu = 1024
memory = 1024
}
service {
port = "outside_careers"
name = "outsidecareers"
provider = "nomad"
}
}
}
}