2
\$\begingroup\$

I recently built a CI for my course project in C. I made 3 stages, to build docker image, compile my C sources and run the said project.

That said, i think i could've do way better here but i don't really know how. I don't have a really big experience with CI, and even if that one works i would like to hear about what you think about it.

What i would like to improve is scalability, generality (there probably will be a need at some point to separate my dockerfiles per subproject (main-atoi is a subproject), ...

Source code here : Gitlab

Docker file

FROM debian:stretch
RUN apt-get update \
&& apt-get install gcc g++ -y
ADD ./ /home
VOLUME /home/build /home/build

.gitlab-ci.yml

stages:
- build-image
- build
- run
before_script:
- docker info
build-image:
 stage: build-image
 tags:
 - build-docker
 script:
 - docker build -t artandor/debian9-cpp:v1-tp1 .
build:
 stage: build
 tags:
 - cours
 script:
 - docker run -v /home/build:/home/build --rm artandor/debian9-cpp:v1-tp1 gcc -Wall -Werror /home/main-atoi/myatoibase.c /home/main-atoi/main-atoi.c -o /home/build/main-test
run:
 stage: run
 dependencies:
 - build
 tags:
 - cours
 script:
 - docker run -v /home/build:/home/build --rm artandor/debian9-cpp:v1-tp1 /home/build/main-test
 - cp /home/build/main-test ./
 artifacts:
 name: "Main Atoi Binary - $CI_COMMIT_REF_NAME"
 paths:
 - ./main-test
asked Oct 2, 2018 at 8:18
\$\endgroup\$
2
  • \$\begingroup\$ I added the code. Sorry for not respecting the guidelines, but it seemed to be a bit big to add it here. Thanks. \$\endgroup\$ Commented Oct 2, 2018 at 9:01
  • 1
    \$\begingroup\$ Actually, that's fairly small for Code Review :-). Thanks for including the code; I hope you get good reviews (I'm not sufficiently skilled with Docker or Gitlab to answer it myself, I'm afraid). \$\endgroup\$ Commented Oct 2, 2018 at 9:13

1 Answer 1

1
\$\begingroup\$

You can have a separate project for your Dockfile and let gitlab keep the image in a container repository. That way you will not need to rebuild the image every build and you can reuse the container in other project without rebuilding it.

answered Oct 22, 2018 at 22:04
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.