Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
afd46ba0
Commit
afd46ba0
authored
4 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Run a test CI"
This reverts commit
2c7dd1f7
.
parent
b0b43785
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+21
-1
21 additions, 1 deletion
.gitlab-ci.yml
Dockerfile.binary
+85
-0
85 additions, 0 deletions
Dockerfile.binary
arkindex/project/settings.py
+2
-1
2 additions, 1 deletion
arkindex/project/settings.py
ci/build.sh
+13
-1
13 additions, 1 deletion
ci/build.sh
with
121 additions
and
3 deletions
.gitlab-ci.yml
+
21
−
1
View file @
afd46ba0
...
...
@@ -129,7 +129,27 @@ backend-build:
-
when
:
never
script
:
-
ci/build.sh
-
ci/build.sh Dockerfile
backend-build-binary
:
stage
:
build
image
:
docker:19.03.1
services
:
-
docker:dind
variables
:
DOCKER_DRIVER
:
overlay2
DOCKER_HOST
:
tcp://docker:2375/
# Run this on master and tags except base tags
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"'
when
:
on_success
-
if
:
'
$CI_COMMIT_TAG
&&
$CI_COMMIT_TAG
!~
/^base-.*/'
when
:
on_success
-
when
:
never
script
:
-
ci/build.sh Dockerfile.binary "-binary"
backend-static-deploy
:
stage
:
deploy
...
...
This diff is collapsed.
Click to expand it.
Dockerfile.binary
0 → 100644
+
85
−
0
View file @
afd46ba0
FROM python:3.7-alpine AS compilation
RUN pip install nuitka
ARG COMMON_BRANCH=master
ARG COMMON_ID=9855787
ARG PONOS_BRANCH=master
ARG PONOS_ID=10017043
ARG GITLAB_TOKEN="gaFM7LRa9zy9QMowcUhx"
# We build in /usr/share because Django will try to load some files relative to that path
# once executed in the binary (management commands, ...)
WORKDIR /usr/share
# Add our own source code
ADD arkindex /usr/share/arkindex
ADD base/requirements.txt /tmp/requirements-base-arkindex.txt
ADD requirements.txt /tmp/requirements-arkindex.txt
# Retrieve common source code
RUN mkdir /tmp/common && \
wget --header "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$COMMON_ID/repository/archive.tar.gz?sha=$COMMON_BRANCH -O /tmp/common.tar.gz && \
tar --strip-components=1 -xvf /tmp/common.tar.gz -C /tmp/common && \
mv /tmp/common/arkindex_common /usr/share
# Retrieve ponos source code
RUN mkdir /tmp/ponos && \
wget --header "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PONOS_ID/repository/archive.tar.gz?sha=$PONOS_BRANCH -O /tmp/ponos.tar.gz && \
tar --strip-components=1 -xvf /tmp/ponos.tar.gz -C /tmp/ponos && \
mv /tmp/ponos/ponos /usr/share
# Build full requirements, removing relative or remote references to arkindex projects
# Special case for apistar, where we want to keep our own fork
# Special case for approximate requirements from ponos, where we want to keep the versions specified from this repo
RUN cat /tmp/common/requirements.txt /tmp/ponos/requirements-server.txt /tmp/requirements-*arkindex.txt | sort | uniq | grep -v -E '^apistar|arkindex|^#|^Django~=|^boto3~=|^cryptography~=|^django-enumfields~=|^djangorestframework~=|^pyyaml~=' > /requirements.txt
# List all management commands
RUN find /usr/share/arkindex/*/management -name '*.py' -not -name '__init__.py' > /commands.txt
# Remove arkindex & ponos unit tests
RUN find /usr/share/arkindex /usr/share/ponos -type d -name tests | xargs rm -rf
# DEBUG
RUN find /usr/share -type f
# Compile all our python source code
RUN apk --update add build-base
RUN python -m nuitka \
--nofollow-imports \
--include-package=arkindex \
--include-package=arkindex_common \
--include-package=ponos \
--show-progress \
--python-flag=-OO \
--lto \
--output-dir=/build \
arkindex/manage.py
# Start over from a clean setup
FROM registry.gitlab.com/arkindex/backend/base:python-3.7 as build
# Import files from compilation
RUN mkdir /usr/share/arkindex
COPY --from=compilation /build/manage.bin /usr/bin/arkindex
COPY --from=compilation /requirements.txt /usr/share/arkindex
COPY --from=compilation /commands.txt /usr/share/arkindex
# Install open source Python dependencies
# We also add gunicorn, to be able to run `arkindex gunicorn`
RUN pip install -r /usr/share/arkindex/requirements.txt gunicorn
# Setup Arkindex VERSION
COPY VERSION /etc/arkindex.version
# Copy templates in base dir for binary
ENV BASE_DIR=/usr/share/arkindex
COPY arkindex/templates /usr/share/arkindex/templates
# Touch python files for needed management commands
# Otherwise Django will not load the compiled module
RUN for cmd in $(cat /usr/share/arkindex/commands.txt); do mkdir -p $(dirname $cmd); touch $cmd; done
# Run gunicorn server
ENV PORT=80
CMD ["arkindex", "gunicorn", "--host=0.0.0.0"]
This diff is collapsed.
Click to expand it.
arkindex/project/settings.py
+
2
−
1
View file @
afd46ba0
...
...
@@ -19,7 +19,8 @@ from pathlib import Path
from
arkindex.project.config
import
get_settings_parser
,
CacheType
# Build paths inside the project like this: BASE_DIR / ...
BASE_DIR
=
Path
(
__file__
).
resolve
().
parent
.
parent
_base_dir
=
os
.
environ
.
get
(
'
BASE_DIR
'
)
BASE_DIR
=
Path
(
_base_dir
)
if
_base_dir
else
Path
(
__file__
).
resolve
().
parent
.
parent
# Used for special cases during configuration parsing and settings loading
TEST_ENV
=
'
test
'
in
sys
.
argv
...
...
This diff is collapsed.
Click to expand it.
ci/build.sh
+
13
−
1
View file @
afd46ba0
...
...
@@ -5,6 +5,13 @@
# Will automatically login to a registry if CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD are set.
# Will only push an image if $CI_REGISTRY is set.
DOCKERFILE
=
$1
TAG_SUFFIX
=
$2
if
[
-z
"
$DOCKERFILE
"
]
;
then
echo
"Missing dockerfile on CLI"
exit
1
fi
if
[
-z
"
$VERSION
"
]
;
then
#Ensure this is not a base tag
case
$CI_COMMIT_TAG
in
...
...
@@ -15,6 +22,11 @@ if [ -z "$VERSION" ]; then
VERSION
=
${
CI_COMMIT_TAG
:-
latest
}
fi
if
[
-n
"
$TAG_SUFFIX
"
]
;
then
# Apply optional suffix to image version
VERSION
=
"
${
VERSION
}${
TAG_SUFFIX
}
"
fi
if
[
-z
"
$VERSION
"
-o
-z
"
$CI_PROJECT_DIR
"
-o
-z
"
$CI_REGISTRY_IMAGE
"
]
;
then
echo
Missing environment variables
exit
1
...
...
@@ -31,7 +43,7 @@ IMAGE_TAG="$CI_REGISTRY_IMAGE:$VERSION"
cd
$CI_PROJECT_DIR
docker pull
"
$CI_REGISTRY_IMAGE
/base:latest"
docker build
.
-t
"
$IMAGE_TAG
"
--build-arg
"PONOS_BRANCH=
$PONOS_BRANCH
"
--build-arg
"COMMON_BRANCH=
$COMMON_BRANCH
"
docker build
.
-f
$DOCKERFILE
-t
"
$IMAGE_TAG
"
--build-arg
"PONOS_BRANCH=
$PONOS_BRANCH
"
--build-arg
"COMMON_BRANCH=
$COMMON_BRANCH
"
if
[
-n
"
$CI_REGISTRY
"
]
;
then
docker push
"
$IMAGE_TAG
"
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment