diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..a480ccb --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,75 @@ +# +# ofilangi +# +# DOCKER_CONTEXT is a context global env variable for all application github p2m2 organization +# - DOCKER_USER -> login +# - DOCKER_PASS -> password +# - ORGANIZATION_NAME -> organization register on dockerhub +# +version: 2.1 +workflows: + docker-publication-workflow: + jobs: + # only develop is build and push on dockerhub ! + - build_branch: + context: + - DOCKER_CONTEXT + filters: + tags: + ignore: /.*/ + branches: + only: + - develop + + # all tags are build and push on dockerhub ! + - build_tag_latest: + context: + - DOCKER_CONTEXT + filters: + tags: + only: /.*/ + branches: + # nothing coming from branch are deployed as latest + ignore: /.*/ + +executors: + docker-publisher: + docker: + - image: circleci/buildpack-deps:stretch + auth: + username: ${DOCKER_USER} + password: ${DOCKER_PASS} + +jobs: + build_branch: + executor: docker-publisher + steps: + - checkout + - setup_remote_docker + - run: + name: Publish Docker Image to Docker Hub + # publication of : + command: | + IMAGE_NAME=${CIRCLE_PROJECT_REPONAME}:${CIRCLE_BRANCH} + + docker build -t ${ORGANIZATION_NAME}/${IMAGE_NAME} . + echo ${DOCKER_PASS} | docker login -u ${DOCKER_USER} --password-stdin + docker push ${ORGANIZATION_NAME}/${IMAGE_NAME} + build_tag_latest: + executor: docker-publisher + steps: + - checkout + - setup_remote_docker + - run: + name: Publish Docker Tag to Docker Hub + # publication of : + command: | + IMAGE_NAME=${CIRCLE_PROJECT_REPONAME}:${CIRCLE_TAG} + IMAGE_NAME_LATEST=${CIRCLE_PROJECT_REPONAME}:latest + + docker build -t ${ORGANIZATION_NAME}/${IMAGE_NAME} . + docker build -t ${ORGANIZATION_NAME}/${IMAGE_NAME_LATEST} . + + echo ${DOCKER_PASS} | docker login -u ${DOCKER_USER} --password-stdin + docker push ${ORGANIZATION_NAME}/${IMAGE_NAME} + docker push ${ORGANIZATION_NAME}/${IMAGE_NAME_LATEST} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..73ecc1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM adoptopenjdk:latest + +RUN apt-get update && apt-get install -y gnupg + +RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list +RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list +RUN curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add + +RUN apt-get update && apt-get install -y sbt + +WORKDIR /workdir +RUN sbt --verbose --version +WORKDIR / + + + diff --git a/README.md b/README.md index 221d014..9b0e006 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # image-scala-sbt Docker image scala-sbt + +```Dockerfile +FROM inraep2m2/image-scala-sbt:latest +```