-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
73 lines (71 loc) · 2.51 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
stages:
- build
- release
build_job:
image: python:3.12-slim
stage: build
only:
- main
services:
- name: postgres:16.3
alias: postgres
variables:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "password"
POSTGRES_DB: "fastapi_boilerplate"
PIP_ONLY_BINARY: ":all:"
PDM_ONLY_BINARY: ":all:"
PDM_CHECK_UPDATE: "false"
APP_NAME: "fastapi-boilerplate"
APP_HOST: "127.0.0.1"
APP_PORT: "4000"
DATABASE_URL: "postgresql://postgres:password@postgres:5432/fastapi_boilerplate?schema=public"
script:
- |
set -eux; \
sed -i "s/deb.debian.org/${APT_DEBIAN_MIRROR_HOST}/g" /etc/apt/sources.list.d/debian.sources; \
apt-get update; \
apt-get install -y --no-install-recommends \
nodejs \
npm \
openssl \
;
- pip install --index-url ${PIP_INDEX_URL} pdm
- python -m venv .venv
- pdm install
- npm config set registry "${NPM_REGISTRY}"
- npm config set "${NPM_REGISTRY_TOKEN_KEY}" "${NPM_REGISTRY_TOKEN_VALUE}"
- pdm run prisma-generate
- pdm run migrate-deploy
- pdm run lint
- pdm run test-cov
- pdm run license-check
release_job:
image: docker:24
stage: release
only:
- main
services:
- docker:24-dind
variables:
DOCKER_TLS_CERTDIR: ""
VERSION: "main"
before_script:
- docker info
script:
- docker login -u $CI_DOCKER_REGISTRY_USERNAME -p $CI_DOCKER_REGISTRY_PASSWORD $CI_DOCKER_REGISTRY
- docker pull $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:latest || true
- |
docker build --cache-from $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:latest \
--build-arg APT_DEBIAN_MIRROR_HOST=${APT_DEBIAN_MIRROR_HOST} \
--build-arg PIP_INDEX_URL=${PIP_INDEX_URL} \
--build-arg PDM_PYPI_URL=${PDM_PYPI_URL} \
--build-arg PDM_PYPI_USERNAME=${PDM_PYPI_USERNAME} \
--build-arg PDM_PYPI_PASSWORD=${PDM_PYPI_PASSWORD} \
--build-arg NPM_REGISTRY=${NPM_REGISTRY} \
--build-arg NPM_REGISTRY_TOKEN_KEY=${NPM_REGISTRY_TOKEN_KEY} \
--build-arg NPM_REGISTRY_TOKEN_VALUE=${NPM_REGISTRY_TOKEN_VALUE} \
--tag $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:$VERSION .
- docker push $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:$VERSION
- docker tag $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:$VERSION $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:latest
- docker push $CI_DOCKER_REGISTRY/cookding/foundation/fastapi-boilerplate:latest