Merge pull request 'Devop setup' (#8) from feature/devop-env into develop
continuous-integration/drone the build was successful Details

Reviewed-on: https://git.roosens.me/Chewing_Bever/hilde/pulls/8
pull/10/head
Jef Roosens 2021-06-25 13:03:17 +02:00
commit 9286a9821c
7 changed files with 218 additions and 1 deletions

5
.dockerignore 100644
View File

@ -0,0 +1,5 @@
*
!Cargo.toml
!Cargo.lock
!src/

13
.editorconfig 100644
View File

@ -0,0 +1,13 @@
root = true
[*]
end_of_line = lf
insert_final_newline = false
indent_size = 4
indent_style = space
[*.{yml,yaml}]
indent_size = 2
[Makefile]
indent_style = tab

77
.woodpecker.yml 100644
View File

@ -0,0 +1,77 @@
pipeline:
# Download the cache from S3
restore-cache:
image: plugins/s3-cache
pull: true
endpoint: https://s3.roosens.me
root: build-cache/
restore: true
secrets: [ cache_s3_access_key, cache_s3_secret_key ]
# =====BUILDING=====
build-backend:
image: rust:1.53-alpine
pull: true
group: build
environment:
- CARGO_HOME=.cargo
commands:
- apk add musl-dev postgresql-dev
- cargo build
# =====TESTING=====
test-backend:
image: rust:1.53-alpine
environment:
- CARGO_HOME=.cargo
commands:
- apk add musl-dev postgresql-dev
- cargo test
# =====LINTING=====
lint-backend:
image: rust:1.53-alpine
group: lint
environment:
- CARGO_HOME=.cargo
commands:
- apk add musl-dev postgresql-dev
- rustup component add rustfmt clippy
- cargo fmt -- --check
# This is run here because it requires compilation
- cargo clippy --all-targets -- -D warnings
# =====REBUILD & FLUSH CACHE=====
rebuild-cache:
image: plugins/s3-cache
endpoint: https://s3.roosens.me
root: build-cache/
rebuild: true
mount:
- target
- .cargo
secrets: [ cache_s3_access_key, cache_s3_secret_key ]
# Push the cache, even on failure
when:
status: [ success, failure ]
flush-cache:
image: plugins/s3-cache
endpoint: https://s3.roosens.me
root: build-cache/
flush: true
flush_age: 14
secrets: [ cache_s3_access_key, cache_s3_secret_key ]
# Push the cache, even on failure
when:
status: [ success, failure ]

45
Cargo.lock generated
View File

@ -84,6 +84,12 @@ version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
[[package]]
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.0.1"
@ -170,6 +176,29 @@ dependencies = [
"syn",
]
[[package]]
name = "diesel"
version = "1.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bba51ca66f57261fd17cadf8b73e4775cc307d0521d855de3f5de91a8f074e0e"
dependencies = [
"bitflags",
"byteorder",
"diesel_derives",
"pq-sys",
]
[[package]]
name = "diesel_derives"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "discard"
version = "1.0.4"
@ -373,6 +402,7 @@ dependencies = [
name = "hilde"
version = "0.1.0"
dependencies = [
"diesel",
"rocket",
]
@ -661,6 +691,15 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "pq-sys"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda"
dependencies = [
"vcpkg",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
@ -1262,6 +1301,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "vcpkg"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70455df2fdf4e9bf580a92e443f1eb0303c390d682e2ea817312c9e81f8c3399"
[[package]]
name = "version_check"
version = "0.9.3"

View File

@ -1,10 +1,11 @@
[package]
name = "hilde"
version = "0.1.0"
authors = ["jjr <roosensjef@gmail.com>"]
authors = ["Jef Roosens <roosensjef@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = "0.5.0-rc.1"
diesel = { version = "1.4.7", features = ["postgres"] }

22
Dockerfile 100644
View File

@ -0,0 +1,22 @@
FROM rust:1.52-alpine3.13 AS builder
WORKDIR /src
# Install build dependencies
RUN apk add --no-cache \
musl-dev \
postgresql-dev
# Copy over source code
COPY Cargo.toml Cargo.lock ./
COPY src ./src/
RUN cargo build \
--release
FROM alpine:3.13
COPY --from=builder /src/target/release/hilde /usr/local/bin/hilde
ENTRYPOINT [ "/usr/local/bin/hilde" ]

54
Makefile 100644
View File

@ -0,0 +1,54 @@
# The main usecase for this Makefile is to simplify database management
all: build
.PHONY: all
# =====CARGO STUFF=====
build:
@ cargo build
.PHONY: build
run:
@ cargo run
.PHONY: run
test:
@ cargo test
.PHONY: test
lint:
@ cargo fmt -- --check
@ cargo clippy --all-targets -- -D warnings
.PHONY: lint
# =====DATABASE STUFF=====
db:
@ docker run \
--rm \
-itd \
-v hilde_db-data:/var/lib/postgresql/data \
-e POSTGRES_USER=hilde \
-e POSTGRES_PASSWORD=hilde \
--name hilde_db \
-p 5432:5432 \
postgres:13-alpine
.PHONY: db
psql:
@ docker exec \
-it hilde_db \
psql -U hilde
.PHONY: psql
stop-db:
@ docker stop hilde_db
.PHONY: stop-db
# =====DOCKER STUFF=====
image:
@ docker build -t hilde:latest .
.PHONY: image