Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOP-22108] Rename backend to server #174

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ SYNCMASTER__AUTH__KEYCLOAK__CLIENT_SECRET=generated_by_keycloak
SYNCMASTER__AUTH__KEYCLOAK__REDIRECT_URI=http://localhost:8000/auth/callback
SYNCMASTER__AUTH__KEYCLOAK__SCOPE=email
SYNCMASTER__AUTH__KEYCLOAK__VERIFY_SSL=False
SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider
SYNCMASTER__AUTH__PROVIDER=syncmaster.server.providers.auth.keycloak_provider.KeycloakAuthProvider

# Dummy Auth
SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.dummy_provider.DummyAuthProvider
SYNCMASTER__AUTH__PROVIDER=syncmaster.server.providers.auth.dummy_provider.DummyAuthProvider
SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=secret

# S3
Expand Down
4 changes: 2 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export SYNCMASTER__AUTH__KEYCLOAK__CLIENT_SECRET=generated_by_keycloak
export SYNCMASTER__AUTH__KEYCLOAK__REDIRECT_URI=http://localhost:8000/auth/callback
export SYNCMASTER__AUTH__KEYCLOAK__SCOPE=email
export SYNCMASTER__AUTH__KEYCLOAK__VERIFY_SSL=False
export SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider
export SYNCMASTER__AUTH__PROVIDER=syncmaster.server.providers.auth.keycloak_provider.KeycloakAuthProvider

# Dummy Auth
export SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.dummy_provider.DummyAuthProvider
export SYNCMASTER__AUTH__PROVIDER=syncmaster.server.providers.auth.dummy_provider.DummyAuthProvider
export SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=secret

export TEST_S3_HOST_FOR_CONFTEST=localhost
Expand Down
4 changes: 2 additions & 2 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
description: Add this label to skip changelog file check
color: 04990f

- name: component:backend
description: Backend-related changes
- name: component:server
description: Server-related changes
color: '5319e7'

- name: component:worker
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/backend_docker_image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backend docker image
name: Server docker image

on:
push:
Expand All @@ -14,7 +14,7 @@ concurrency:

jobs:
release:
name: Build & push backend image to Dockerhub
name: Build & push server image to Dockerhub
runs-on: ubuntu-latest
if: github.repository == 'MobileTeleSystems/syncmaster' # prevent running on forks

Expand All @@ -38,22 +38,22 @@ jobs:
id: set_tag
run: |
if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" == "develop" ]]; then
echo "TAG=mtsrus/syncmaster-backend:develop" >> $GITHUB_ENV
echo "TAG=mtsrus/syncmaster-server:develop" >> $GITHUB_ENV
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "TAG=mtsrus/syncmaster-backend:latest,mtsrus/syncmaster-backend:${{ github.ref_name }}" >> $GITHUB_ENV
echo "TAG=mtsrus/syncmaster-server:latest,mtsrus/syncmaster-server:${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Build Backend image
- name: Build Server image
uses: docker/build-push-action@v6
with:
tags: ${{ env.TAG }}
context: .
target: prod
file: docker/Dockerfile.backend
file: docker/Dockerfile.server
pull: true
push: true
cache-to: type=inline
cache-from: mtsrus/syncmaster-backend:develop
cache-from: mtsrus/syncmaster-server:develop
platforms: |
linux/amd64
linux/arm64/v8
Expand All @@ -76,6 +76,6 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# this requires token with read+write+delete permissions. read+write is not enough!
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: mtsrus/syncmaster-backend
repository: mtsrus/syncmaster-server
short-description: ${{ github.event.repository.description }}
enable-url-completion: true
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
run: poetry run flake8 syncmaster/

- name: Run mypy
run: poetry run mypy --config-file ./pyproject.toml ./syncmaster/backend
run: poetry run mypy --config-file ./pyproject.toml ./syncmaster/server

codeql:
name: CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Generate OpenAPI Schema
run: |
source .env.local
poetry run python -m syncmaster.backend.scripts.export_openapi_schema openapi.json
poetry run python -m syncmaster.server.scripts.export_openapi_schema openapi.json
- name: Fix logo in Readme
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: |
source .env.local
poetry run python -m syncmaster.db.migrations upgrade head
poetry run coverage run -m pytest -vvv -s -m "backend or scheduler"
poetry run coverage run -m pytest -vvv -s -m "server or scheduler"
- name: Shutdown
if: always()
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ repos:
- id: chmod
args: ['644']
exclude_types: [shell]
exclude: ^(.*__main__\.py|syncmaster/backend/scripts/export_openapi_schema\.py)$
exclude: ^(.*__main__\.py|syncmaster/server/scripts/export_openapi_schema\.py)$
- id: chmod
args: ['755']
types: [shell]
- id: chmod
args: ['755']
files: ^(.*__main__\.py|syncmaster/backend/scripts/export_openapi_schema\.py)$
files: ^(.*__main__\.py|syncmaster/server/scripts/export_openapi_schema\.py)$
- id: insert-license
files: .*\.py$
exclude: ^(syncmaster/backend/dependencies/stub.py|docs/.*\.py|tests/.*\.py)$
exclude: ^(syncmaster/server/dependencies/stub.py|docs/.*\.py|tests/.*\.py)$
args:
- --license-filepath
- .spdx-license-header.txt
Expand Down Expand Up @@ -109,7 +109,7 @@ repos:

- id: mypy
name: mypy
entry: mypy ./syncmaster/backend --config-file ./pyproject.toml
entry: mypy ./syncmaster/server --config-file ./pyproject.toml
language: python
require_serial: true
pass_filenames: false
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ It allows to keep development environment the same for all developers due to usi

There are *extra* dependencies (included into package as optional):

* ``backend`` - for running backend
* ``server`` - for running server
* ``worker`` - for running Celery workers

And *groups* (not included into package, used locally and in CI):
Expand Down Expand Up @@ -330,7 +330,7 @@ Examples for adding changelog entries to your Pull Requests
.. code-block:: rst
:caption: docs/changelog/next_release/2345.bugfix.rst
Fixed behavior of ``backend`` -- by :github:user:`someuser`
Fixed behavior of ``server`` -- by :github:user:`someuser`
.. code-block:: rst
:caption: docs/changelog/next_release/3456.feature.rst
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ test-cleanup: ##@Test Cleanup tests dependencies


dev-server: db-start ##@Application Run development server (without docker)
${POETRY} run python -m syncmaster.backend $(ARGS)
${POETRY} run python -m syncmaster.server $(ARGS)

dev-worker: db-start broker-start ##@Application Run development broker (without docker)
${POETRY} run python -m celery -A syncmaster.worker.celery worker --max-tasks-per-child=1 $(ARGS)



prod-build-server: ##@Application Build docker image for server
docker build --progress=plain -t mtsrus/syncmaster-backend:develop -f ./docker/Dockerfile.backend --target=prod $(ARGS) .
docker build --progress=plain -t mtsrus/syncmaster-server:develop -f ./docker/Dockerfile.server --target=prod $(ARGS) .

prod-build-scheduler: ##@Application Build docker image for scheduler
docker build --progress=plain -t mtsrus/syncmaster-scheduler:develop -f ./docker/Dockerfile.scheduler --target=prod $(ARGS) .
Expand Down Expand Up @@ -164,4 +164,4 @@ docs-cleanup: ##@Docs Cleanup docs
docs-fresh: docs-cleanup docs-build ##@Docs Cleanup & build docs

openapi: ##@Docs Generate OpenAPI schema
python -m syncmaster.backend.scripts.export_openapi_schema docs/_static/openapi.json
python -m syncmaster.server.scripts.export_openapi_schema docs/_static/openapi.json
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Data.SyncMaster
:target: https://github.com/MobileTeleSystems/syncmaster/blob/develop/LICENSE.txt
.. |PyPI Python Version| image:: https://img.shields.io/pypi/pyversions/data-syncmaster.svg
:target: https://badge.fury.io/py/data-syncmaster
.. |Docker image| image:: https://img.shields.io/docker/v/mtsrus/syncmaster-backend?sort=semver&label=docker
:target: https://hub.docker.com/r/mtsrus/syncmaster-backend
.. |Docker image| image:: https://img.shields.io/docker/v/mtsrus/syncmaster-server?sort=semver&label=docker
:target: https://hub.docker.com/r/mtsrus/syncmaster-server
.. |Documentation| image:: https://readthedocs.org/projects/syncmaster/badge/?version=stable
:target: https://syncmaster.readthedocs.io
.. |Build Status| image:: https://github.com/MobileTeleSystems/syncmaster/workflows/Run%20All%20Tests/badge.svg
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
timeout: 5s
retries: 3

# Using worker image here to skip building backend image build in CI.
# Using worker image here to skip building server image build in CI.
# Worker test image already has all neccessary dependencies
migrations:
image: mtsrus/syncmaster-worker:${WORKER_IMAGE_TAG:-test}
Expand All @@ -46,11 +46,11 @@ services:
db:
condition: service_healthy

backend:
image: mtsrus/syncmaster-backend:${BACKEND_IMAGE_TAG:-test}
server:
image: mtsrus/syncmaster-server:${SERVER_IMAGE_TAG:-test}
restart: unless-stopped
build:
dockerfile: docker/Dockerfile.backend
dockerfile: docker/Dockerfile.server
context: .
target: test
env_file: .env.docker
Expand All @@ -75,7 +75,7 @@ services:
timeout: 5s
retries: 3
start_period: 5s
profiles: [backend, all]
profiles: [server, all]

scheduler:
image: mtsrus/syncmaster-scheduler:${SCHEDULER_IMAGE_TAG:-test}
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ services:
retries: 3

migrations:
image: mtsrus/syncmaster-backend:${TAG:-develop}
image: mtsrus/syncmaster-server:${TAG:-develop}
restart: no
build:
dockerfile: docker/Dockerfile.backend
dockerfile: docker/Dockerfile.server
context: .
target: prod
entrypoint: [python, -m, syncmaster.db.migrations, upgrade, head]
Expand All @@ -41,11 +41,11 @@ services:
db:
condition: service_healthy

backend:
image: mtsrus/syncmaster-backend:${TAG:-develop}
server:
image: mtsrus/syncmaster-server:${TAG:-develop}
restart: unless-stopped
build:
dockerfile: docker/Dockerfile.backend
dockerfile: docker/Dockerfile.server
context: .
target: prod
ports:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.scheduler
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV PYTHONPATH=/app
COPY ./pyproject.toml ./poetry.lock* /app/

RUN pip install --upgrade pip setuptools wheel packaging
RUN poetry install --no-root --extras "scheduler" --extras "backend" --without test,docs,dev
RUN poetry install --no-root --extras "scheduler" --extras "server" --without test,docs,dev

COPY ./docker/entrypoint_scheduler.sh /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
Expand Down
16 changes: 8 additions & 8 deletions docker/Dockerfile.backend → docker/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ ENV PYTHONPATH=/app
COPY ./pyproject.toml ./poetry.lock* /app/

RUN pip install --upgrade pip setuptools wheel packaging
RUN poetry install --no-root --extras "backend" --without test,docs,dev
RUN poetry install --no-root --extras "server" --without test,docs,dev

COPY ./docker/entrypoint_backend.sh /app/entrypoint.sh
COPY ./docker/entrypoint_server.sh /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]


FROM base AS prod

COPY ./syncmaster/ /app/syncmaster/
# add this when logo will be ready
# COPY ./docs/_static/*.svg ./syncmaster/backend/static/
# COPY ./docs/_static/*.svg ./syncmaster/server/static/

# Swagger UI
ADD https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui-bundle.js /app/syncmaster/backend/static/swagger/swagger-ui-bundle.js
ADD https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui.css /app/syncmaster/backend/static/swagger/swagger-ui.css
ADD https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui-bundle.js /app/syncmaster/server/static/swagger/swagger-ui-bundle.js
ADD https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui.css /app/syncmaster/server/static/swagger/swagger-ui.css

# Redoc
ADD https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js /app/syncmaster/backend/static/redoc/redoc.standalone.js
ADD https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js /app/syncmaster/server/static/redoc/redoc.standalone.js

ENV SYNCMASTER__SERVER__OPENAPI__SWAGGER__JS_URL=/static/swagger/swagger-ui-bundle.js \
SYNCMASTER__SERVER__OPENAPI__SWAGGER__CSS_URL=/static/swagger/swagger-ui.css \
SYNCMASTER__SERVER__OPENAPI__REDOC__JS_URL=/static/redoc/redoc.standalone.js \
SYNCMASTER__SERVER__STATIC_FILES__DIRECTORY=/app/syncmaster/backend/static
SYNCMASTER__SERVER__STATIC_FILES__DIRECTORY=/app/syncmaster/server/static


FROM base AS test

RUN poetry install --no-root --extras "backend" --with test --without docs,dev
RUN poetry install --no-root --extras "server" --with test --without docs,dev
RUN sed -i 's/python -m/coverage run -m/g' /app/entrypoint.sh
4 changes: 2 additions & 2 deletions docker/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["--loglevel=info"]


FROM base as prod
FROM base AS prod

COPY ./syncmaster/ /app/syncmaster/

Expand All @@ -46,6 +46,6 @@ FROM base AS test

ENV SYNCMASTER__WORKER__CREATE_SPARK_SESSION_FUNCTION=tests.spark.get_worker_spark_session

# CI runs tests in the worker container, so we need backend dependencies too
# CI runs tests in the worker container, so we need server dependencies too
RUN poetry install --no-root --all-extras --with test --without docs,dev
RUN sed -i 's/python -m/coverage run -m/g' /app/entrypoint.sh
6 changes: 3 additions & 3 deletions docker/entrypoint_backend.sh → docker/entrypoint_server.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set -e

if [[ "x${SYNCMASTER__ENTRYPOINT__SUPERUSERS}" != "x" ]]; then
superusers=$(echo "${SYNCMASTER__ENTRYPOINT__SUPERUSERS}" | tr "," " ")
python -m syncmaster.backend.scripts.manage_superusers add ${superusers}
python -m syncmaster.backend.scripts.manage_superusers list
python -m syncmaster.server.scripts.manage_superusers add ${superusers}
python -m syncmaster.server.scripts.manage_superusers list
fi

# exec is required to forward all signals to the main process
exec python -m syncmaster.backend --host 0.0.0.0 --port 8000 "$@"
exec python -m syncmaster.server --host 0.0.0.0 --port 8000 "$@"
Loading
Loading