refactor: project dev structure
Diff
.dockerignore | 1 +-
.gitignore | 3 ++-
Makefile | 4 +--
Makefile.toml | 12 +++++++++-
Tasks.Dev.toml | 21 +----------------
Tasks.Prod.toml | 53 +----------------------------------------
docker/envoy/.dockerignore | 9 +-------
docker/envoy/docker-compose.yml | 36 +---------------------------
docker/envoy/docker-entrypoint.sh | 6 +-----
docker/envoy/sw.envoy.dockerfile | 15 +-----------
sample.env | 9 +++++++-
11 files changed, 27 insertions(+), 142 deletions(-)
@@ -9,3 +9,4 @@
*docker-compose*
Makefile
target
**/*.env
@@ -12,4 +12,7 @@
**/*.tar
**/*.gz
**/.DS_Store
**/*.env
release
!sample.env
@@ -26,12 +26,12 @@ install:
run:
@rustc -vV
@cargo make --makefile Tasks.Dev.toml run
@cargo make --makefile Makefile.toml run
.PHONY: run
dev:
@rustc -vV
@cargo make --makefile Tasks.Dev.toml watch
@cargo make --makefile Makefile.toml watch
.PHONY: dev
build:
@@ -0,0 +1,12 @@
env_files = [
{ path = "./development.env", profile = "development" },
{ path = "./production.env", profile = "production" }
]
[tasks.watch]
command = "cargo"
args = ["watch", "-cx", "run -- ${E_ARGS}"]
[tasks.run]
command = "cargo"
args = ["run", "--", "${E_ARGS}"]
@@ -1,21 +0,0 @@
[env]
E_ARGS = "--port=8787"
E_URL = "http://locahost"
SERVER_LOG_LEVEL = "trace"
SERVER_ROOT = "./public"
SERVER_ASSETS = "./public/assets"
SERVER_CORS_ALLOW_ORIGINS = "*"
[tasks.watch]
command = "cargo"
args = ["watch", "-cx", "run -- ${E_ARGS}"]
[tasks.run]
command = "cargo"
args = ["run", "--", "${E_ARGS}"]
[tasks.loadtest]
script = [
"echo GET $E_URL | vegeta -cpus=12 attack -workers=10 -duration=60s -connections=10000 -rate=200 -http2=true | tee results.bin | vegeta report",
"cat results.bin | vegeta report -reporter=plot > plot.html"
]
@@ -1,53 +0,0 @@
[env]
PKG_PLATFORM = "x86_64-unknown-linux-musl"
PKG_NAME = { script = ["cat Cargo.toml | awk 'match($0, /name = \"(.*)\"/, v) {print v[1]}'"] }
PKG_VERSION = { script = ["cat Cargo.toml | awk 'match($0, /version = \"([0-9.].+)\"/, v) {print v[1]}'"] }
PKG_BIN_DIR = "./bin"
PKG_BIN_PATH = "${PKG_BIN_DIR}/${PKG_NAME}"
[tasks.clean_artifacts]
command = "cargo"
args = ["clean"]
[tasks.clean_bin]
script = ["rm -rf bin"]
[tasks.clean]
dependencies = [
"clean_artifacts",
"clean_bin"
]
[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["clean"]
[tasks.mkdir]
script = ["mkdir -p ${PKG_BIN_DIR}"]
[tasks.copy]
script = ["cp -rf target/${PKG_PLATFORM}/release/${PKG_NAME} ${PKG_BIN_DIR}"]
[tasks.strip]
script = ["strip ${PKG_BIN_PATH}"]
[tasks.size]
script = ["du -sh ${PKG_BIN_PATH}"]
[tasks.build]
command = "cargo"
args = ["build", "--release", "--target", "${PKG_PLATFORM}"]
[tasks.docker_image]
script = ["docker build -t ${PKG_NAME} -f ./docker/sws.dockerfile ."]
[tasks.release]
dependencies = [
"clean",
"build",
"mkdir",
"copy",
"strip",
"size"
]
@@ -1,9 +0,0 @@
*.~
.git
**/*.gz
**/*.log
**/*.tar
**/.DS_Store
.gitignore
*docker-compose*
Makefile
@@ -1,36 +0,0 @@
version: "3.3"
services:
service1:
image: static-web-server:latest
environment:
- SERVER_HOST=127.0.0.1
- SERVER_PORT=8080
- SERVER_NAME=Server-1
- SERVICE_NAME=service1
volumes:
- ./envoy-service.yaml:/etc/envoy-service.yaml
deploy:
replicas: 1
update_config:
parallelism: 1
restart_policy:
condition: on-failure
networks:
envoymesh:
aliases:
- service1
networks:
envoymesh:
external:
name: envoymesh
@@ -1,6 +0,0 @@
set -e
/bin/static-web-server &
/usr/local/bin/envoy -c /etc/envoy-service.yaml --service-cluster ${SERVICE_NAME}
@@ -1,15 +0,0 @@
FROM envoyproxy/envoy-alpine:36f39c746eb7d03b762099b206403935b11972d8
LABEL maintainer=https://git.io/joseluisq
RUN set -ex \
&& apk update && apk add --no-cache bash ca-certificates
ADD bin /bin
ADD public /public
ADD docker/docker-entrypoint.sh /entrypoint.sh
RUN chmod u+x /bin/static-web-server \
&& chmod u+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
@@ -0,0 +1,9 @@
E_ARGS = "--port=8787"
SERVER_LOG_LEVEL = "trace"
SERVER_ROOT = "./public"
SERVER_ASSETS = "./public/assets"
SERVER_CORS_ALLOW_ORIGINS = "*"