add ci pipeline
This commit is contained in:
parent
488db81749
commit
7b73c53d7d
2 changed files with 60 additions and 0 deletions
37
.gitlab-ci.yml
Normal file
37
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
|
||||||
|
run tests:
|
||||||
|
image: dlang2/dmd-ubuntu:2.083.1
|
||||||
|
script:
|
||||||
|
- dub test
|
||||||
|
|
||||||
|
auto build and push:
|
||||||
|
image: docker:stable
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
||||||
|
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- build
|
||||||
|
|
||||||
|
build and push:
|
||||||
|
image: docker:stable
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
||||||
|
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||||
|
except:
|
||||||
|
- master
|
||||||
|
when: manual
|
||||||
|
tags:
|
||||||
|
- build
|
23
Dockerfile
Normal file
23
Dockerfile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
FROM dlang2/dmd-ubuntu:2.083.1 as build
|
||||||
|
WORKDIR /dlang/d-webservice-example
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN dub build --build=release
|
||||||
|
|
||||||
|
FROM ubuntu:17.10
|
||||||
|
EXPOSE 8080
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN set -ex && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install --no-install-recommends -y \
|
||||||
|
ca-certificates \
|
||||||
|
libssl1.0.0
|
||||||
|
|
||||||
|
COPY --from=build /dlang/d-webservice-example/d-webservice-example /dlang/d-webservice-example/d-webservice-example
|
||||||
|
|
||||||
|
RUN useradd --user-group --create-home --shell /bin/false app && \
|
||||||
|
chown -R app:app /dlang/d-webservice-example
|
||||||
|
USER app
|
||||||
|
|
||||||
|
CMD ["/dlang/d-webservice-example/d-webservice-example]
|
Loading…
Reference in a new issue