Skip to content

Commit

Permalink
Don't compile since source is available (#106)
Browse files Browse the repository at this point in the history
* Don't compile since source is available

* Fix config error

* Readd push to reqs and remove unused local enterprise dockerfile

* Fixing release version var and removing unneeded enterprise config.py

* Fix staging upload?

* Fix staging upload?

* Fix typo in token
  • Loading branch information
trent-codecov authored Sep 8, 2023
1 parent dc288f8 commit 3aca979
Show file tree
Hide file tree
Showing 27 changed files with 51 additions and 741 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ jobs:
- run:
name: codecov-staging
command: |
chmod +x codecov-alpine
./codecov-alpine -R . --url https://stage-web.codecov.dev -t $CODECOV_STAGING_TOKEN -F unit
codecovcli do-upload --flag unit-latest-uploader --flag unit -t ${CODECOV_STAGING_TOKEN} \
--coverage-files-search-exclude-folder=graphql_api/types/** \
--coverage-files-search-exclude-folder=api/internal/tests/unit/views/cassetes/**
portable:
executor: codecov-deploy
steps:
Expand Down
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ coverage.xml
*.log
.git
service.json
.github
.circleci
90 changes: 0 additions & 90 deletions Dockerfile.circle-enterprise

This file was deleted.

87 changes: 24 additions & 63 deletions Dockerfile.enterprise
Original file line number Diff line number Diff line change
@@ -1,85 +1,46 @@
FROM codecov/api:latest as build
ARG REQUIREMENTS_IMAGE=codecov/api:latest

FROM $REQUIREMENTS_IMAGE as build

COPY . /app
WORKDIR /app

# Pyinstaller necessities
# PyInstaller needs zlib-dev, gcc, libc-dev, and musl-dev
RUN apk --update --no-cache add \
zlib-dev \
musl-dev \
libc-dev \
libffi-dev \
gcc \
g++ \
git \
pwgen \
&& pip install --upgrade pip

RUN pip install pyinstaller==4.7
RUN pip uninstall -y typing
# install cython
RUN pip install cython==3.0a9
RUN pip install tinyaes

# set settings module
ENV DJANGO_SETTINGS_MODULE "codecov.settings_enterprise"

# Remove the settings dev and enterprise files.
# These should *never* make it to enterprise.
RUN rm /app/codecov/settings_dev.py
RUN rm /app/codecov/settings_prod.py
RUN rm /app/codecov/settings_test.py
RUN rm /app/codecov/settings_staging.py
RUN rm /app/codecov/settings_dev.py && \
rm /app/codecov/settings_prod.py && \
rm /app/codecov/settings_test.py && \
rm /app/codecov/settings_staging.py && \
rm /app/dev.sh && \
rm /app/prod.sh && \
rm /app/staging.sh && \
rm /app/production.yml && \
rm /app/development.yml

# Remove unneeded folders
RUN rm -rf /app/.github
RUN rm -rf /app/.circleci

# Remove and rewrite the settings module to the
# enterprise variant. This removes all reference to
# dev and prod settings.
RUN rm /app/utils/config.py
COPY enterprise/config.py /app/utils/config.py


# execute Cython script in app dir
COPY enterprise/ldd /pyinstaller/ldd
COPY enterprise/setup.py setup.py
COPY enterprise/cythonize.sh /pyinstaller/cythonize_everything.sh


COPY enterprise/pyi_rth_django.py /pyinstaller/pyi_rth_django.py
COPY enterprise/generate_pyinstaller_args.py /pyinstaller/generate_pyinstaller_args.py

#Copy Hooks
COPY enterprise/hooks /hooks

# Not the cleanest, but this helps with layer caching.
RUN chmod a+x /pyinstaller/*
RUN ["/pyinstaller/cythonize_everything.sh"]

COPY enterprise/package.sh /pyinstaller/package.sh
RUN chmod a+x /pyinstaller/*
RUN ["/pyinstaller/package.sh"]
ENV RUN_ENV=ENTERPRISE
# Create the codecov user to run the container as
RUN addgroup -S application && adduser -S codecov -G application
RUN mkdir -p /config && chown codecov:application /config

# copy the enterprise settings module.
WORKDIR /home
COPY ./enterprise.sh /home/enterprise.sh
RUN chown codecov:application /home/enterprise.sh && \
chmod +x /home/enterprise.sh && \
chown codecov:application /home/api
WORKDIR /app
RUN chmod +x enterprise.sh && \
chown codecov:application /app

FROM alpine:3.16

RUN addgroup -S application && adduser -S codecov -G application && rm -rf /home/codecov
USER codecov
COPY --from=build /home/enterprise.sh /home/enterprise
COPY --from=build /home/api /home/api
ARG RELEASE_VERSION
ENV RELEASE_VERSION $RELEASE_VERSION
ENV DJANGO_SETTINGS_MODULE "codecov.settings_enterprise"
ENV RUN_ENV="ENTERPRISE"
ENV RELEASE_VERSION=$RELEASE_VERSION
ENV DJANGO_SETTINGS_MODULE="codecov.settings_enterprise"
ENV CODECOV_API_PORT=8000
WORKDIR /home
ENTRYPOINT ["./enterprise"]

ENTRYPOINT ["./enterprise.sh"]

23 changes: 5 additions & 18 deletions Dockerfile.enterprise_runtime
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,21 @@

ARG CODECOV_ENTERPRISE_RELEASE

FROM $CODECOV_ENTERPRISE_RELEASE as release


FROM python:3.9.14-alpine3.16

RUN addgroup -S application && adduser -S codecov -G application
FROM $CODECOV_ENTERPRISE_RELEASE

USER root
ARG RELEASE_VERSION
ENV RELEASE_VERSION $RELEASE_VERSION
ENV RELEASE_VERSION=$RELEASE_VERSION
ENV DJANGO_SETTINGS_MODULE "codecov.settings_enterprise"
ENV CODECOV_API_PORT=8000

WORKDIR /home
COPY --from=release /home /home

ENV RUN_ENV="ENTERPRISE"
ARG EXTERNAL_DEPS_FOLDER=./external_deps

RUN mkdir $EXTERNAL_DEPS_FOLDER
RUN pip install --target $EXTERNAL_DEPS_FOLDER psycopg2-binary tlslite-ng
RUN chown codecov:application $EXTERNAL_DEPS_FOLDER

# Remove (crudelly) python installation
RUN rm /usr/local/bin/* && \
rm -r /usr/local/include/python3.9 && \
rm -r /usr/local/lib/python3.9 && \
rm /usr/local/lib/pkgconfig/python* && \
rm /usr/local/lib/libpython3*

USER codecov

ENTRYPOINT ["./enterprise"]
ENTRYPOINT ["./enterprise.sh"]
23 changes: 0 additions & 23 deletions Dockerfile.local-enterprise

This file was deleted.

3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ epoch := $(shell date +"%s")
build.local:
DOCKER_BUILDKIT=1 docker build -f Dockerfile . -t codecov/api:latest --ssh default

build.enterprise.local:
DOCKER_BUILDKIT=1 docker build -f Dockerfile.local-enterprise . -t codecov/enterprise-api:latest-stable --ssh default

build.base:
DOCKER_BUILDKIT=1 docker build -f Dockerfile.requirements . -t codecov/baseapi:latest --ssh default

Expand Down
9 changes: 6 additions & 3 deletions Makefile.circle
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ build:
build-enterprise:
docker pull ${GCR_REPO}:${REQUIREMENTS_TAG}
docker build \
-f Dockerfile.circle-enterprise . \
-f Dockerfile.enterprise . \
-t ${ENTERPRISE_GCR_REPO}:latest_no_dependencies \
--build-arg REQUIREMENTS_IMAGE=${GCR_REPO}:${REQUIREMENTS_TAG}
--build-arg REQUIREMENTS_IMAGE=${GCR_REPO}:${REQUIREMENTS_TAG} \
--build-arg RELEASE_VERSION=${VERSION}
docker push ${ENTERPRISE_GCR_REPO}:latest_no_dependencies

# CIRCLECI
# job: enterprise-runtime
Expand All @@ -65,7 +67,8 @@ build-enterprise-runtime:
docker build \
-f Dockerfile.enterprise_runtime . \
-t ${ENTERPRISE_GCR_REPO}:latest \
--build-arg CODECOV_ENTERPRISE_RELEASE=${ENTERPRISE_GCR_REPO}:latest_no_dependencies
--build-arg CODECOV_ENTERPRISE_RELEASE=${ENTERPRISE_GCR_REPO}:latest_no_dependencies \
--build-arg RELEASE_VERSION=${VERSION}

# CIRCLECI
# job: portable
Expand Down
Binary file removed codecov-alpine
Binary file not shown.
66 changes: 0 additions & 66 deletions enterprise.py

This file was deleted.

Loading

0 comments on commit 3aca979

Please sign in to comment.