This commit is contained in:
Piotr Biernat 2022-12-02 22:05:47 +01:00
commit e7fa2a6589
7 changed files with 105 additions and 0 deletions

36
.drone.yml Normal file
View File

@ -0,0 +1,36 @@
kind: pipeline
type: docker
name: default
steps:
- name: publish_image
image: plugins/docker
environment:
DOCKER_USERNAME:
from_secret: registry_username
DOCKER_PASSWORD:
from_secret: registry_password
commands:
- sleep 5
- ./deploy/image-build.sh
- ./deploy/image-push.sh
volumes:
- name: docker-sock
path: /var/run
when:
branch:
- main
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: docker-sock
path: /var/run
volumes:
- name: gopath
temp: {}
- name: docker-sock
temp: {}

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM hashicorp/consul:1.14
LABEL dev.egommerce.image.author="Piotr Biernat"
LABEL dev.egommerce.image.vendor="Egommerce"
LABEL dev.egommerce.image.service="api-registry"
LABEL dev.egommerce.image.version="1.0"
COPY ./api-registry/etc /consul/config
RUN cat /usr/local/bin/docker-entrypoint.sh
EXPOSE 8500 8600 8600/udp
# USER consul
ENTRYPOINT ["consul", "agent", "-config-dir=/consul/config"]
# CMD ["consul", "agent", "-config-dir=/consul/config"]
# ENTRYPOINT ["docker-entrypoint.sh"]

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
DEPLOY_DIR := ./deploy
SRC_DIR := ./src
## DEPLOY PART
build-image-dev:
- sh ${DEPLOY_DIR}/image-build.sh dev
build-image-prod:
- sh ${DEPLOY_DIR}/image-build.sh
push-image-prod:
- sh ${DEPLOY_DIR}/image-push.sh

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# api-registry
API Registry - based on Consul

View File

@ -0,0 +1,14 @@
{
"node_name": "api-registry",
"server": true,
"bootstrap" : true,
"ui_config": {
"enabled" : true
},
"data_dir": "/consul/data",
"addresses": {
"http" : "0.0.0.0"
},
"bind_addr": "0.0.0.0",
"advertise_addr": "127.0.0.1"
}

16
deploy/image-build.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# RUN IN REPO ROOT DIR !!
export IMAGE_NAME="git.pbiernat.dev/egommerce/api-registry"
TARGET=${1:-latest}
echo "Building: $IMAGE_NAME:$TARGET"
if [ $TARGET = "dev" ]
then
docker build --rm --no-cache -t "$IMAGE_NAME:dev" . # >/dev/null 2>&1
else
docker build --rm --cache-from "$IMAGE_NAME:$TARGET" -t "$IMAGE_NAME:$TARGET" . >/dev/null 2>&1
fi
echo "Done."

7
deploy/image-push.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# RUN IN REPO ROOT DIR !!
export IMAGE_NAME="git.pbiernat.dev/egommerce/api-registry"
echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin
docker push "$IMAGE_NAME:latest"