Compare commits
17 Commits
21c8e0e832
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 45f2c61c17 | |||
| dd30ade94b | |||
| 587287fb82 | |||
| 78788f05e3 | |||
| 87d81bb447 | |||
| 52427c453e | |||
| 6e5d4e39e7 | |||
| ea1bc210c6 | |||
| acee9670d0 | |||
| c2cf7bc905 | |||
| aca87e3db1 | |||
| 54ed8d999f | |||
| afee68fa90 | |||
| 32f943ac34 | |||
| 50834327da | |||
| 79f2ea8d10 | |||
| 0948d3e768 |
16
.github/workflows/pipeline.yml
vendored
16
.github/workflows/pipeline.yml
vendored
@@ -46,6 +46,7 @@ jobs:
|
|||||||
images: liamsgit.dev/LiamPietralla/code-snippets
|
images: liamsgit.dev/LiamPietralla/code-snippets
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest
|
type=raw,value=latest
|
||||||
|
type=sha,value=${{ github.sha }}
|
||||||
|
|
||||||
- name: Login to Registry
|
- name: Login to Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -98,5 +99,16 @@ jobs:
|
|||||||
ansible-playbook infra/ansible/deploy-playbook.yml --private-key private.key --inventory hosts.ini
|
ansible-playbook infra/ansible/deploy-playbook.yml --private-key private.key --inventory hosts.ini
|
||||||
env:
|
env:
|
||||||
APP_HOST: ${{ secrets.APP_HOST }}
|
APP_HOST: ${{ secrets.APP_HOST }}
|
||||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
# - name: Setup Nomad
|
||||||
|
# uses: hashicorp/setup-nomad@main
|
||||||
|
# with:
|
||||||
|
# nomad_version: '1.10.5'
|
||||||
|
|
||||||
|
# - name: Deploy Job to Nomad
|
||||||
|
# run: |
|
||||||
|
# nomad job run -var="version=${{ github.sha }}" infra/nomad/code-snippets.nomad.hcl
|
||||||
|
# env:
|
||||||
|
# NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ export default defineConfig({
|
|||||||
{ text: 'Local DB (PostgreSQL)', link: '/docker/local-db-pg' },
|
{ text: 'Local DB (PostgreSQL)', link: '/docker/local-db-pg' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'Docker Swarm',
|
||||||
|
link: '/docker-swarm/',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'EF Core',
|
text: 'EF Core',
|
||||||
link: '/ef-core/',
|
link: '/ef-core/',
|
||||||
@@ -119,6 +123,14 @@ export default defineConfig({
|
|||||||
{ text: 'Custom Fetch', link: '/nuxt/custom-fetch' },
|
{ text: 'Custom Fetch', link: '/nuxt/custom-fetch' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'Postgres',
|
||||||
|
link: '/postgres/',
|
||||||
|
collapsed: true,
|
||||||
|
items: [
|
||||||
|
{ text: 'Dump and Restore', link: '/postgres/dump-and-restore' },
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'PowerShell',
|
text: 'PowerShell',
|
||||||
link: '/powershell/',
|
link: '/powershell/',
|
||||||
|
|||||||
27
docs/docker-swarm/index.md
Normal file
27
docs/docker-swarm/index.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Docker Swarm Snippets and Musings
|
||||||
|
|
||||||
|
## Updating Services
|
||||||
|
|
||||||
|
View services:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker service ls
|
||||||
|
```
|
||||||
|
|
||||||
|
To scale a service up or down:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker service scale <service_name>=<number_of_replicas>
|
||||||
|
```
|
||||||
|
|
||||||
|
Sometimes services get stuck or need to be forcefully updated:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker service update --force <service_name>
|
||||||
|
```
|
||||||
|
|
||||||
|
::: tip
|
||||||
|
|
||||||
|
Sometimes if you need to force containers to restart use the update force (e.g. after restarting a node).
|
||||||
|
|
||||||
|
:::
|
||||||
@@ -26,6 +26,10 @@ hero:
|
|||||||
text: Docker
|
text: Docker
|
||||||
link: /docker/
|
link: /docker/
|
||||||
|
|
||||||
|
- theme: alt
|
||||||
|
text: Docker Swarm
|
||||||
|
link: /docker-swarm/
|
||||||
|
|
||||||
- theme: alt
|
- theme: alt
|
||||||
text: EF Core
|
text: EF Core
|
||||||
link: /ef-core/
|
link: /ef-core/
|
||||||
@@ -46,6 +50,10 @@ hero:
|
|||||||
text: Nuxt
|
text: Nuxt
|
||||||
link: /nuxt/
|
link: /nuxt/
|
||||||
|
|
||||||
|
- theme: alt
|
||||||
|
text: Postgres
|
||||||
|
link: /postgres/
|
||||||
|
|
||||||
- theme: alt
|
- theme: alt
|
||||||
text: PowerShell
|
text: PowerShell
|
||||||
link: /powershell/
|
link: /powershell/
|
||||||
|
|||||||
39
docs/postgres/dump-and-restore.md
Normal file
39
docs/postgres/dump-and-restore.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Dump and Restore
|
||||||
|
|
||||||
|
Handy commands for dumping and restoring Postgres databases.
|
||||||
|
|
||||||
|
::: info
|
||||||
|
Most of these commands are run using Docker as then we don't need to have Postgres installed locally.
|
||||||
|
|
||||||
|
If a different version of Postgres is needed, just change the version number in the Docker image tag.
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Create a pgpass file in the current directory with the following content:
|
||||||
|
|
||||||
|
```
|
||||||
|
<server>:<port>:<database>:<username>:<password>
|
||||||
|
```
|
||||||
|
|
||||||
|
::: tip
|
||||||
|
Use `*` as a wildcard for any of the fields except for the password.
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Dumping a Database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --network host --rm -v .:/tmp -v ./pgpass:/root/.pgpass -e PGPASSFILE=/root/.pgpass postgres:16 bash -c "chmod 600 /root/.pgpass && pg_dump -h <server> -p <port> -U <username> <database> -f /tmp/$(date +%Y%m%d_%H%M%S)_<database>_dump.sql -c --if-exists"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dumping a Cluster
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --network host --rm -v .:/tmp -v ./pgpass:/root/.pgpass -e PGPASSFILE=/root/.pgpass postgres:16 bash -c "chmod 600 /root/.pgpass && pg_dumpall -h <server> -p <port> -U <username> -f /tmp/$(date +%Y%m%d_%H%M%S)_<server>_cluster_dump.sql -c --if-exists"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Restoring from a SQL Dump
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --network host --rm -v .:/tmp -v ./pgpass:/root/.pgpass -e PGPASSFILE=/root/.pgpass postgres:16 bash -c "chmod 600 /root/.pgpass && psql -h <server> -p <port> -U <username> <database> -f /tmp/dump.sql -X"
|
||||||
|
```
|
||||||
3
docs/postgres/index.md
Normal file
3
docs/postgres/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Postgres Snippets and Musings
|
||||||
|
|
||||||
|
#### [Dump and Restore](./dump-and-restore.md)
|
||||||
46
infra/nomad/code-snippets.nomad.hcl
Normal file
46
infra/nomad/code-snippets.nomad.hcl
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
variable "version" {
|
||||||
|
type = string
|
||||||
|
default = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
job "code-snippets" {
|
||||||
|
datacenters = ["dc1"]
|
||||||
|
type = "service"
|
||||||
|
|
||||||
|
group "code-snippets" {
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
network {
|
||||||
|
port "http" {
|
||||||
|
to = 80
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task "code-snippets" {
|
||||||
|
driver = "docker"
|
||||||
|
|
||||||
|
config {
|
||||||
|
image = "liamsgit.dev/LiamPietralla/code-snippets:${var.version}"
|
||||||
|
force_pull = true
|
||||||
|
ports = ["http"]
|
||||||
|
}
|
||||||
|
|
||||||
|
service {
|
||||||
|
name = "code-snippets"
|
||||||
|
port = "http"
|
||||||
|
tags = [
|
||||||
|
"traefik.enable=true",
|
||||||
|
"traefik.http.routers.code-snippets.rule=PathPrefix(`/`)",
|
||||||
|
"traefik.http.routers.code-snippets.entrypoints=p5003"
|
||||||
|
]
|
||||||
|
|
||||||
|
check {
|
||||||
|
type = "http"
|
||||||
|
path = "/"
|
||||||
|
interval = "10s"
|
||||||
|
timeout = "2s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user