Verified Commit 33ee3217 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

first commit

parents
stages:
- test
- build
- publish
default:
image: rust:alpine
###############
# Stage: test #
###############
test:
stage: test
before_script:
- rustup self update
- rustup component add clippy
- apk update
- apk add cmake openssl-dev build-base
script:
- cargo test
- cargo clippy
except:
- tags
################
# Stage: build #
################
build:
stage: build
before_script:
- apk update
- apk add musl-dev upx build-base cmake openssl-dev
script:
- cargo build --release
- strip target/release/dummy-server
- upx --best -q --lzma target/release/dummy-server
- mv target/release/dummy-server app
artifacts:
name: "${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
paths:
- app
expire_in: 1 hour
public: false
when: on_success
##################
# Stage: publish #
##################
.build-image:
stage: publish
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile.ci --destination $IMAGE_TAG
build-tagged-image:
extends: .build-image
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$BIN_NAME-$CI_COMMIT_TAG"
only:
- tags
build-latest-image:
extends: .build-image
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$BIN_NAME-latest"
only:
- master
build-feature-branch-image:
extends: .build-image
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$BIN_NAME-$CI_COMMIT_REF_NAME"
except:
- master
- tags
pages:
stage: publish
only:
- master
before_script:
- apk update
- apk add cmake openssl-dev build-base
script:
- cargo doc --no-deps
- mv target/doc public
artifacts:
paths:
- public
This diff is collapsed.
[package]
name = "dummy-server"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.12.0", features = ["macros", "rt-multi-thread"] }
warp = "0.3.1"
[profile.release]
# Optimize for size
opt-level = 'z'
lto = true
codegen-units = 1
panic = 'abort'
FROM index.docker.io/library/rust:alpine AS build
ARG APPNAME=kafkaesque
RUN apk update && apk add musl-dev upx build-base cmake openssl-dev
WORKDIR /buildenv
RUN USER=root cargo new -q --vcs none --bin $APPNAME
WORKDIR /buildenv/$APPNAME
COPY Cargo.toml .
COPY Cargo.lock .
RUN cargo build --release
RUN rm -r src && rm -f ./target/release/deps/$APPNAME*
COPY src/ src/
RUN cargo build --release && strip ./target/release/$APPNAME && upx --best -q --lzma ./target/release/$APPNAME
RUN mkdir /build && mv ./target/release/$APPNAME /build/app
FROM scratch
WORKDIR /app
COPY --from=build /build/app app
ENTRYPOINT ["./app", "./config/config.toml"]
FROM scratch
WORKDIR /app
COPY app app
PORT 80
ENTRYPOINT ["/app/app"]
# Dummy Server
A very small and dumb web server for testing purposes
use warp::Filter;
#[tokio::main]
async fn main() {
let hello = warp::path::end().map(|| "hello world!");
warp::serve(hello).run(([0, 0, 0, 0], 80)).await;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment