Newer
Older
.prepare_pipenv: &prepare_pipenv |
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
pip install pipenv --ignore-installed
set +e
pipenv --venv; NO_VENV=$? ; echo 'No fail'
set -e
if [ $NO_VENV -eq 1 ]; then
pipenv install --dev
.prepare_awscli: &prepare_awscli |
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
pip install pipenv --ignore-installed
set +e
pipenv --venv; NO_VENV=$? ; echo 'No fail'
set -e
if [ $NO_VENV -eq 1 ]; then
fi
pipenv run pip install awscli
.get_ecscli: &get_ecscli |
if [ -e ecs-cli ]
then
echo "ecs-cli already downloaded"
else
apk add curl
curl -o ./ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
fi
chmod +x ecs-cli
variables:
GIT_SUBMODULE_STRATEGY: recursive
DOCKER_TLS_CERTDIR: ""
build_image_prod:
stage: build
image: docker
services:
- docker:dind
before_script:
- apk --no-cache add --virtual git build-base gcc libgcc musl-dev jpeg-dev zlib-dev libc-dev libffi-dev mariadb-dev openssl-dev python3-dev py3-pip
- *prepare_awscli
script:
- $(pipenv run aws ecr get-login --no-include-email --region eu-west-1 )
- |
set +e
- docker build --cache-from "${AWS_REGISTRY_IMAGE}:$CI_COMMIT_REF_NAME" -t "${AWS_REGISTRY_IMAGE}:$CI_COMMIT_REF_NAME" .
- docker push "$AWS_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
only:
- tags
cache:
key: docker
paths:
- .venv
- .pip-cache
- Pipfile.lock
deploy_prod:
stage: deploy
environment: production
before_script:
- *get_ecscli
only:
- tags
script:
- source backend/production.env
- ./ecs-cli configure --region eu-west-1 --cluster spotfleet-gitlab
- ./ecs-cli compose --file ecs-compose.yml --ecs-params ecs-params.yml --project-name saf-prod service up --create-log-groups --target-group-arn $AWS_TG_ARN --container-name saf --container-port 80 --timeout 10 --role $AWS_ROLE
cache:
key: python
paths:
- .venv
- .pip-cache
- Pipfile.lock
- ecs-cli
build_image_staging:
stage: build
image: docker
services:
- docker:dind
before_script:
- apk --no-cache add --virtual git build-base gcc libgcc musl-dev jpeg-dev zlib-dev libc-dev libffi-dev mariadb-dev openssl-dev python3-dev py3-pip
- *prepare_awscli
script:
- $(pipenv run aws ecr get-login --no-include-email --region eu-west-1 )
- |
set +e
docker pull "${AWS_REGISTRY_IMAGE}:PREPROD-$CI_COMMIT_REF_NAME"
- docker build --cache-from "${AWS_REGISTRY_IMAGE}:PREPROD-$CI_COMMIT_REF_NAME" -t "${AWS_REGISTRY_IMAGE}:PREPROD-$CI_COMMIT_REF_NAME" .
- docker push "$AWS_REGISTRY_IMAGE:PREPROD-$CI_COMMIT_REF_NAME"
except:
- tags
cache:
key: docker
paths:
- .venv
- .pip-cache
- Pipfile.lock
deploy_staging:
stage: deploy
environment: staging
before_script:
- *get_ecscli
except:
- tags
script:
- source backend/staging.env
- ./ecs-cli configure --region eu-west-1 --cluster spotfleet-gitlab
- ./ecs-cli compose --file ecs-compose.yml --ecs-params ecs-params.yml --project-name saf-stag service up --create-log-groups --target-group-arn $AWS_TG_ARN --container-name saf --container-port 80 --timeout 10 --role $AWS_ROLE
cache:
key: python
paths:
- .venv
- .pip-cache
- Pipfile.lock
- ecs-cli
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
build_prod_front:
stage: build
when: manual
image: node:latest
script:
- cd frontend/SAF_vue
- npm install -g @vue/cli@latest
- npm install
- npm run build
- mv dist ../..
artifacts:
paths:
- dist/
expire_in: 1 hour
deploy_prod_front:
stage: deploy
needs:
- job: build_prod_front
image: python:latest
script:
- pip install awscli
- aws s3 sync ./dist s3://lem-usb-front