Compare commits

..

6 Commits

Author SHA1 Message Date
Minghe
9e9cdeb3ee enable timestamp on image (#556)
* enable timestamp on image

* fix name issue
2020-07-09 21:25:55 +08:00
Minghe Huang
c17434703e disable k8s relate unit test for now 2020-06-28 00:48:19 +08:00
Minghe Huang
0644eb285a disable k8s relate unit test for now 2020-06-28 00:38:34 +08:00
Minghe
0f4120c2c8 fix wrong way to take user and host from env (#552) 2020-06-28 00:27:54 +08:00
FrontMage
ba43561f40 Rust multistage build (#550)
* fix get request not accepted

* use mutli-stage docker build to minimize final image

Co-authored-by: Minghe <h.minghe@gmail.com>
2020-06-17 14:16:31 +08:00
Minghe Huang
046226b580 add vistors 2020-06-13 13:10:32 +08:00
8 changed files with 47 additions and 16 deletions

View File

@@ -27,7 +27,7 @@ jobs:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
export KUBECONFIG="$(kind get kubeconfig-path)"
# export KUBECONFIG="$(kind get kubeconfig-path)"
make unit-test
bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}

View File

@@ -32,7 +32,7 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
export KUBECONFIG="$(kind get kubeconfig-path)"
# export KUBECONFIG="$(kind get kubeconfig-path)"
make unit-test
- name: build fx

View File

@@ -8,7 +8,8 @@ Poor man's function as a service.
[![CodeCov](https://codecov.io/gh/metrue/fx/branch/master/graph/badge.svg)](https://codecov.io/gh/metrue/fx)
[![Go Report Card](https://goreportcard.com/badge/github.com/metrue/fx?style=flat-square)](https://goreportcard.com/report/github.com/metrue/fx)
[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/metrue/fx)
![](https://img.shields.io/github/license/metrue/fx.svg)
![visitors](https://visitor-badge.glitch.me/badge?page_id=https://github.com/metrue/fx)
![liscense](https://img.shields.io/github/license/metrue/fx.svg)
[![Release](https://img.shields.io/github/release/metrue/fx.svg?style=flat-square)](https://github.com/metrue/fx/releases/latest)
## Table of Contents

View File

@@ -1,7 +1,12 @@
FROM liuchong/rustup
WORKDIR /usr/src/myapp
FROM clux/muslrust:nightly AS builder
WORKDIR /build
COPY . .
RUN cp ./config ~/.cargo/ && rustup default nightly && cargo build
RUN ln -s /usr/bin/g++ /usr/bin/musl-g++ && cargo build --release
FROM scratch
WORKDIR /usr/src/myapp
COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/rust /usr/src/myapp/
COPY ./Rocket.toml /usr/src/myapp/
EXPOSE 3000
CMD ["cargo", "run"]
ENV ROCKET_ENV=prod
CMD ["/usr/src/myapp/rust"]

View File

@@ -1,5 +1,23 @@
[development]
address = "localhost"
port = 3000
workers = 8
keep_alive = 5
log = "normal"
limits = { forms = 32768 }
[staging]
address = "0.0.0.0"
port = 3000
workers = 8
keep_alive = 5
log = "normal"
limits = { forms = 32768 }
[production]
address = "0.0.0.0"
port = 3000
workers = 8
keep_alive = 5
log = "critical"
limits = { forms = 32768 }

2
fx.go
View File

@@ -19,7 +19,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)
const version = "0.9.43"
const version = "0.9.45"
func init() {
go checkForUpdate()

View File

@@ -44,7 +44,7 @@ func Build(ctx context.Contexter) (err error) {
language := ctx.Get("language").(string)
host := ctx.Get("host").(string)
kubeconf := ctx.Get("kubeconf").(string)
name := ctx.Get("name").(string)
name := fmt.Sprintf("%s-%s", ctx.Get("name").(string), time.Now().Format("20060102150405"))
if err := bundle.Bundle(workdir, language, fn, deps...); err != nil {
return err
@@ -63,7 +63,7 @@ func Build(ctx context.Contexter) (err error) {
if err := docker.BuildImage(ctx.GetContext(), workdir, name); err != nil {
return err
}
nameWithTag := name + ":latest"
nameWithTag := fmt.Sprintf("%s:latest", name)
if err := docker.TagImage(ctx.GetContext(), name, nameWithTag); err != nil {
return err
}

View File

@@ -24,10 +24,8 @@ func set(ctx context.Contexter, cli *cli.Context, fields []argsField) error {
if len(addr) != 2 {
return fmt.Errorf("invalid host information, should be format of <user>@<ip>")
}
user := addr[0]
ip := addr[1]
ctx.Set("host", ip)
ctx.Set("user", user)
ctx.Set("host", addr[1])
ctx.Set("user", addr[0])
} else {
ctx.Set(f.Name, cli.String(f.Name))
}
@@ -38,7 +36,16 @@ func set(ctx context.Contexter, cli *cli.Context, fields []argsField) error {
}
if f.Env != "" && os.Getenv(f.Env) != "" {
ctx.Set(f.Name, os.Getenv(f.Env))
if f.Name == "host" {
info := strings.Split(os.Getenv(f.Env), "@")
if len(info) != 2 {
return fmt.Errorf("invalid host information, should be format of <user>@<ip>")
}
ctx.Set("host", info[1])
ctx.Set("user", info[0])
} else {
ctx.Set(f.Name, os.Getenv(f.Env))
}
}
}
return nil