Skip to content

Commit

Permalink
Merge pull request #1182 from breatheco-de/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tommygonzaleza authored Nov 22, 2023
2 parents 25a053c + fe58509 commit a6a4ba7
Show file tree
Hide file tree
Showing 49 changed files with 1,311 additions and 736 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/new-relic-change-tracking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Change Tracking Marker

on:
push: {}


jobs:

newrelic-prod:
runs-on: ubuntu-latest
name: New Relic
if: >-
github.repository == 'breatheco-de/apiv2' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
steps:

# This step builds a var with the release tag value to use later
- name: Set Release Version from Tag
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV

# This step creates a new Change Tracking Marker
- name: New Relic Application Deployment Marker
uses: newrelic/[email protected]
with:
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID }}
version: "${{ env.RELEASE_VERSION }}"
user: "${{ github.actor }}"

newrelic-dev:
runs-on: ubuntu-latest
name: New Relic
if: >-
github.repository == 'breatheco-de/apiv2' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/development'
steps:

# This step builds a var with the release tag value to use later
- name: Set Release Version from Tag
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV

# This step creates a new Change Tracking Marker
- name: New Relic Application Deployment Marker
uses: newrelic/[email protected]
with:
apiKey: ${{ secrets.NEW_RELIC_API_KEY_DEV }}
guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID_DEV }}
version: "${{ env.RELEASE_VERSION }}"
user: "${{ github.actor }}"
59 changes: 59 additions & 0 deletions .heroku.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM newrelic/infrastructure:latest as infrastructure

FROM heroku/heroku:22

COPY --from=infrastructure /usr/bin/newrelic-infra /usr/bin/newrelic-infra
COPY --from=infrastructure /usr/bin/newrelic-infra-ctl /usr/bin/newrelic-infra-ctl
COPY --from=infrastructure /usr/bin/newrelic-infra-service /usr/bin/newrelic-infra-service
COPY --from=infrastructure /newrelic /newrelic

ENV NEW_RELIC_LICENSE_KEY $NEW_RELIC_LICENSE_KEY

RUN apt update -y \
&& apt install -y -qq software-properties-common curl \
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& apt update -y -qq \
&& apt upgrade -y -qq \
&& apt install -y -qq --no-install-recommends software-properties-common curl libcap2-bin \
python3.11 python3.11-dev pip libpq-dev libboost-all-dev kmod sudo \
&& apt clean -y -qq \
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*

RUN python3.11 -m pip install pipenv && \
python3.11 -m pip cache purge && \
rm -rf $HOME/.cache/pipenv /tmp/*

RUN useradd -ms /bin/bash 4geeks

RUN mkdir /var/run/newrelic-infra
RUN mkdir /var/db
RUN mkdir /var/db/newrelic-infra
RUN mkdir /var/db/newrelic-infra/data
RUN chown -R 4geeks:4geeks /var/run/newrelic-infra
RUN chown -R 4geeks:4geeks /var/db/newrelic-infra
RUN chown -R 4geeks:4geeks /var/db/newrelic-infra/data

RUN touch /etc/newrelic-infra.yml
RUN chown 4geeks:4geeks /etc/newrelic-infra.yml

USER 4geeks
ENV NRIA_MODE="UNPRIVILEGED"

COPY . /app
WORKDIR /app

ENV NEW_RELIC_APP_NAME ${NEW_RELIC_APP_NAME}
ENV NEW_RELIC_LICENSE_KEY ${NEW_RELIC_LICENSE_KEY}
ENV NEW_RELIC_LOG ${NEW_RELIC_LOG}
ENV NEW_RELIC_API_KEY ${NEW_RELIC_API_KEY}
ENV NEW_RELIC_ACCOUNT_ID ${NEW_RELIC_ACCOUNT_ID}
ENV NRIA_LICENSE_KEY ${NEW_RELIC_LICENSE_KEY}

RUN echo $NEW_RELIC_LICENSE_KEY
RUN echo ${NEW_RELIC_LICENSE_KEY}

RUN pipenv install --system --deploy --ignore-pipfile && \
python3.11 -m pip cache purge && \
rm -rf $HOME/.cache/pipenv /tmp/*

# RUN newrelic-infra
51 changes: 51 additions & 0 deletions .newrelic.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM newrelic/infrastructure:latest

RUN echo "license_key: $NEW_RELIC_LICENSE_KEY" | tee -a /etc/newrelic-infra.yml

RUN apk upgrade && \
apk add --no-cache curl gnupg python3 python3-dev py3-pip libpq boost-dev postgresql-dev libcap py3-pip py3-numpy py3-scipy \
musl-dev linux-headers gcc g++ cmake build-base cython libstdc++ gfortran wget freetype-dev libpng-dev openblas-dev \
git bash jemalloc-dev autoconf zlib-dev flex bison py3-numpy py3-scipy libffi-dev openssl-dev apache-arrow && \
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --upgrade pip setuptools pipenv && \
adduser -D 4geeks && \
mkdir -p /app

RUN ln -s /usr/include/locale.h /usr/include/xlocale.h

ARG ARROW_VERSION=14.0.1
ARG ARROW_SHA1=2ede75769e12df972f0acdfddd53ab15d11e0ac2
ARG ARROW_BUILD_TYPE=release

ENV ARROW_HOME=/usr/local \
PARQUET_HOME=/usr/local

RUN mkdir /mnt/arrow \
&& cd /mnt/arrow \
&& curl -L -o apache-arrow-${ARROW_VERSION}.tar.gz \
https://github.com/apache/arrow/archive/refs/tags/apache-arrow-${ARROW_VERSION}.tar.gz \
&& tar -xzvf apache-arrow-${ARROW_VERSION}.tar.gz \
&& cd arrow-apache-arrow-${ARROW_VERSION} \
&& ls

USER 4geeks
ENV NRIA_MODE="UNPRIVILEGED"

COPY . /app
WORKDIR /app

RUN python3 --version
RUN python3.11 --version

RUN pipenv install --system --deploy --ignore-pipfile && \
pip3 cache purge && \
rm -rf $HOME/.cache/pipenv /tmp/*


RUN newrelic-infra


RUN newrelic profile configure --accountId $NEW_RELIC_ACCOUNT_ID --apiKey $NEW_RELIC_API_KEY && \
/usr/bin/newrelic install -n logs-integration
#
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ PROJECT_ID := test

# docker image for BigQuery emulator
BQ_EMULATOR_IMAGE := ghcr.io/goccy/bigquery-emulator:latest
NEW_RELIC_METADATA_COMMIT := $(shell git rev-parse HEAD)

new-relic:
@echo ${NEW_RELIC_LICENSE_KEY}
@echo "license_key: ${NEW_RELIC_LICENSE_KEY}" | tee -a /etc/newrelic-infra.yml
newrelic-infra

release:
@export CORALOGIX_SUBSYSTEM=web; \
export NEW_RELIC_METADATA_COMMIT=${NEW_RELIC_METADATA_COMMIT}; \
# newrelic-admin run-program bin/start-pgbouncer-stunnel \
gunicorn breathecode.wsgi --timeout 29 --workers ${WEB_WORKERS} \
--worker-connections ${WEB_WORKER_CONNECTION} --worker-class ${WEB_WORKER_CLASS}

web:
@export CORALOGIX_SUBSYSTEM=web; \
export NEW_RELIC_METADATA_COMMIT=${NEW_RELIC_METADATA_COMMIT}; \
# newrelic-admin run-program bin/start-pgbouncer-stunnel \
gunicorn breathecode.wsgi --timeout 29 --workers ${WEB_WORKERS} \
--worker-connections ${WEB_WORKER_CONNECTION} --worker-class ${WEB_WORKER_CLASS}

# target to run the test, it does not work yet, maybe it must be removed
test:
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ redis = {extras = ["hiredis"], version = "*"}
brotli = "*"
circuitbreaker = "*"
kombu = "*"
zstandard = "*"
Loading

0 comments on commit a6a4ba7

Please sign in to comment.