Skip to content

Commit

Permalink
add circleci config
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis-Florin Rendler authored and rendler-denis committed May 25, 2020
1 parent 87ab8c7 commit 39d192c
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 30 deletions.
114 changes: 114 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# CircleCI build and deployment for safenotes
#
version: 2.1

executors:
golang-exec:
docker:
- image: circleci/golang:1.14.2
user: root
working_directory: /safenotes

jobs:
tests-run:
executor: golang-exec
steps:
- checkout
- run:
name: Running backend tests
command: make test

release-docker-image-version:
executor: golang-exec
steps:
- checkout
- run:
name: Prepare .safenote.yaml
command: cp configs/.safenotes.yaml.example .safenotes.build.yaml
- run:
name: Prepare .env.production
command: cp configs/react.env.example webapp/react/.env.production
- setup_remote_docker:
version: 19.03.8
- run:
name: Build The Docker Image
command: make release-docker TAG=<< pipeline.git.tag >> REPO=$IMAGE_REPO
- run:
name: Deploy to Docker Hub
command: |
echo $DOCKER_TOKEN | docker login --username $DOCKER_LOGIN --password-stdin
docker push $IMAGE_REPO:<< pipeline.git.tag >>
- run:
name: Dump image to tar.gz
command: |
mkdir artifacts
docker image save -o artifacts/safenotes.docker.tar.gz $IMAGE_REPO:<< pipeline.git.tag >>
- persist_to_workspace:
root: artifacts/
paths:
- safenotes.docker.tar.gz

release-docker-image-latest:
executor: golang-exec
steps:
- attach_workspace:
at: artifacts/
- setup_remote_docker:
version: 19.03.8
- run:
name: Deploy 'latest' tag to Docker Hub
command: |
echo "Loading image to daemon..."
docker image load -i artifacts/safenotes.docker.tar.gz
echo "Tagging image..."
docker image tag $IMAGE_REPO:<< pipeline.git.tag >> $IMAGE_REPO:latest
echo "Pushing image to Docker Hub..."
echo $DOCKER_TOKEN | docker login --username $DOCKER_LOGIN --password-stdin
docker push $IMAGE_REPO:latest
workflows:
version: 2
run-tests:
jobs:
- tests-run:
filters:
branches:
only:
- master

docker-release:
jobs:
- tests-run:
filters:
tags:
only: /^[0-9\.]*/
branches:
ignore: /.*/
- release-docker-image-version:
context: docker_hub
filters:
tags:
only: /^[0-9\.]*/
branches:
ignore: /.*/
requires:
- tests-run

- hold:
type: approval
filters:
tags:
only: /^[0-9\.]*/
branches:
ignore: /.*/

- release-docker-image-latest:
context: docker_hub
filters:
tags:
only: /^[0-9\.]*/
branches:
ignore: /.*/
requires:
- release-docker-image-version
- hold
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ build:

.PHONY: release-docker
release-docker:
@if [ ! -f '.safenotes.prod.yaml' ]; then echo ">>> Missing .safenotes.prod.yaml" && exit 1; fi;
DOCKER_BUILDKIT=1 docker build --target PROD -f build/docker/Dockerfile ${OPTS} --tag safenotes:${TAG} .
@if [ ! -f '.safenotes.build.yaml' ]; then echo ">>> Missing .safenotes.build.yaml" && exit 1; fi;
DOCKER_BUILDKIT=1 docker build --target PROD -f build/docker/Dockerfile ${OPTS} --tag ${REPO}:${TAG} .

.PHONY: react-dev
react-dev:
Expand Down
2 changes: 1 addition & 1 deletion build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ LABEL "Maintainer"="Denis Rendler <[email protected]>" \

COPY --from=build_fe /project/build/ /safenotes/www
COPY --from=build_be /project/dist/safenotes /safenotes/safenotes
COPY --from=build_be /project/.safenotes.prod.yaml /safenotes/.safenotes.yaml
COPY --from=build_be /project/.safenotes.build.yaml /safenotes/.safenotes.yaml

WORKDIR /safenotes

Expand Down
1 change: 1 addition & 0 deletions configs/react.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PUBLIC_URL=

0 comments on commit 39d192c

Please sign in to comment.