1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

updates from review, WIP

This commit is contained in:
Lee Brown
2019-08-22 17:33:47 -08:00
parent d3b97a6608
commit 998d1bf13e
15 changed files with 158 additions and 25 deletions

7
build/README.md Normal file
View File

@ -0,0 +1,7 @@
# `/build`
Packaging and Continuous Integration.
Put your cloud (AMI), container (Docker), OS (deb, rpm, pkg) package configurations and scripts in the /build/package
directory.

View File

@ -200,6 +200,13 @@ If you have a lot of migrations, it can be a pain to run all them. For example,
the app into a clean database. To prevent this, use the initSchema function that will run as-if no migration was run
before (in a new clean database).
**Migrations should be backwards compatible with the existing deployed code.** Refrain from `drop table`. Instead of
renaming columns, add a new column and copy the data from the old column using an `update`.
Ideally migrations should be idempotent to avoid possible data loss since data could have been generated between
migration runs.
Another bonus with the globally defined schema is that it enables your testing package the ability to dynamically [spin
up database containers](https://gitlab.com/geeks-accelerator/oss/saas-starter-kit/blob/issue8/datadog-lambda-func/internal/platform/tests/main.go#L127)
on-demand and automatically include all the migrations. This allows the testing package to

View File

@ -0,0 +1,19 @@
FROM datadog/agent:latest
LABEL maintainer="lee@geeksinthewoods.com"
#COPY go_expvar.conf.yaml /etc/datadog-agent/conf.d/go_expvar.d/conf.yaml
COPY custom-init.sh /custom-init.sh
ARG service
ENV SERVICE_NAME $service
ARG env="dev"
ENV ENV $env
ARG gogc="10"
ENV GOGC $gogc
ENV DD_TAGS="source:docker service:${service} service_name:${service} cluster:NA env:${ENV}"
CMD ["/custom-init.sh"]

View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
configFile="/etc/datadog-agent/conf.d/go_expvar.d/conf.yaml"
echo -e "init_config:\n\ninstances:\n" > $configFile
if [[ "${DD_EXPVAR}" != "" ]]; then
while IFS='|' read -ra HOSTS; do
for h in "${HOSTS[@]}"; do
if [[ "${h}" == "" ]]; then
continue
fi
url=""
for p in $h; do
k=`echo $p | awk -F '=' '{print $1}'`
v=`echo $p | awk -F '=' '{print $2}'`
if [[ "${k}" == "url" ]]; then
url=$v
break
fi
done
if [[ "${url}" == "" ]]; then
echo "No url param found in '${h}'"
continue
fi
echo -e " - expvar_url: ${url}" >> $configFile
if [[ "${DD_TAGS}" != "" ]]; then
echo " tags:" >> $configFile
for t in ${DD_TAGS}; do
echo " - ${t}" >> $configFile
done
fi
for p in $h; do
k=`echo $p | awk -F '=' '{print $1}'`
v=`echo $p | awk -F '=' '{print $2}'`
if [[ "${k}" == "url" ]]; then
continue
fi
echo " - ${k}:${v}" >> $configFile
done
done
done <<< "$DD_EXPVAR"
else :
echo -e " - expvar_url: http://localhost:80/debug/vars" >> $configFile
if [[ "${DD_TAGS}" != "" ]]; then
echo " tags:" >> $configFile
for t in ${DD_TAGS}; do
echo " - ${t}" >> $configFile
done
fi
fi
cat $configFile
/init