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

Skip building frontend when APP_ENV=dev #4843

Closed
wants to merge 3 commits into from
Closed
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
30 changes: 22 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ jobs:
environment:
COMPOSE_FILE: .circleci/docker-compose.circle.yml
COMPOSE_PROJECT_NAME: redash
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
docker:
- image: circleci/buildpack-deps:xenial
- image: circleci/buildpack-deps:focal
steps:
- setup_remote_docker
- setup_remote_docker:
version: 18.09.3
- checkout
- run:
name: Build Docker Images
Expand All @@ -36,21 +39,29 @@ jobs:
docker-compose build --build-arg skip_ds_deps=true
docker-compose up -d
sleep 10
- run:
name: Build Front End Assets for some testcases # TODO: Fix testcases and remove this step
command: |
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
npm ci
npm run build
docker cp ./client/dist $(docker-compose ps -q redash):/app/client/
Comment on lines +42 to +49
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some backend unit testcases depend on frontend.

- run:
name: Create Test Database
command: docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;"
command: docker-compose exec postgres psql -U postgres -c "create database tests;"
- run:
name: List Enabled Query Runners
command: docker-compose run --rm redash manage ds list_types
command: docker-compose exec redash /app/bin/docker-entrypoint manage ds list_types
- run:
name: Run Tests
command: docker-compose run --name tests redash tests --junitxml=junit.xml --cov-report xml --cov=redash --cov-config .coveragerc tests/
command: docker-compose exec redash /app/bin/docker-entrypoint tests --junitxml=junit.xml --cov-report xml --cov=redash --cov-config .coveragerc tests/
- run:
name: Copy Test Results
command: |
mkdir -p /tmp/test-results/unit-tests
docker cp tests:/app/coverage.xml ./coverage.xml
docker cp tests:/app/junit.xml /tmp/test-results/unit-tests/results.xml
docker cp $(docker-compose ps -q redash):/app/coverage.xml ./coverage.xml
docker cp $(docker-compose ps -q redash):/app/junit.xml /tmp/test-results/unit-tests/results.xml
when: always
- store_test_results:
path: /tmp/test-results
Expand Down Expand Up @@ -82,13 +93,16 @@ jobs:
environment:
COMPOSE_FILE: .circleci/docker-compose.cypress.yml
COMPOSE_PROJECT_NAME: cypress
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
PERCY_TOKEN_ENCODED: ZGRiY2ZmZDQ0OTdjMzM5ZWE0ZGQzNTZiOWNkMDRjOTk4Zjg0ZjMxMWRmMDZiM2RjOTYxNDZhOGExMjI4ZDE3MA==
CYPRESS_PROJECT_ID_ENCODED: OTI0Y2th
CYPRESS_RECORD_KEY_ENCODED: YzA1OTIxMTUtYTA1Yy00NzQ2LWEyMDMtZmZjMDgwZGI2ODgx
docker:
- image: circleci/node:12
steps:
- setup_remote_docker
- setup_remote_docker:
version: 18.09.3
- checkout
- run:
name: Install npm dependencies
Expand Down
6 changes: 4 additions & 2 deletions .circleci/docker-compose.circle.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: '3'
services:
redash:
build: ../
command: manage version
build:
context: ../
args:
APP_ENV: dev
depends_on:
- postgres
- redis
Expand Down
6 changes: 3 additions & 3 deletions .circleci/docker_build
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ docker login -u $DOCKER_USER -p $DOCKER_PASS

if [ $CIRCLE_BRANCH = master ] || [ $CIRCLE_BRANCH = preview-image ]
then
docker build -t redash/redash:preview -t redash/preview:$VERSION_TAG .
DOCKER_BUILDKIT=1 docker build -t redash/redash:preview -t redash/preview:$VERSION_TAG .
docker push redash/redash:preview
docker push redash/preview:$VERSION_TAG
else
docker build -t redash/redash:$VERSION_TAG .
DOCKER_BUILDKIT=1 docker build -t redash/redash:$VERSION_TAG .
docker push redash/redash:$VERSION_TAG
fi

echo "Built: $VERSION_TAG"
echo "Built: $VERSION_TAG"
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG APP_ENV=prod

FROM node:12 as frontend-builder

WORKDIR /frontend
Expand All @@ -8,7 +10,7 @@ COPY client /frontend/client
COPY webpack.config.js /frontend/
RUN npm run build

FROM python:3.7-slim
FROM python:3.7-slim as server

EXPOSE 5000

Expand Down Expand Up @@ -41,7 +43,7 @@ RUN apt-get update && \
libsasl2-dev \
unzip \
libsasl2-modules-gssapi-mit && \
# MSSQL ODBC Driver:
# MSSQL ODBC Driver:
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
Expand All @@ -62,14 +64,25 @@ WORKDIR /app
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1

# We first copy only the requirements file, to avoid rebuilding on every file
# change.
FROM server as dev-server

COPY requirements.txt requirements_bundles.txt requirements_dev.txt requirements_all_ds.txt ./
RUN pip install -r requirements.txt -r requirements_dev.txt
RUN if [ "x$skip_ds_deps" = "x" ] ; then pip install -r requirements_all_ds.txt ; else echo "Skipping pip install -r requirements_all_ds.txt" ; fi

COPY . /app

FROM server as prod-server

COPY requirements.txt requirements_bundles.txt requirements_all_ds.txt ./
RUN pip install -r requirements.txt
RUN if [ "x$skip_ds_deps" = "x" ] ; then pip install -r requirements_all_ds.txt ; else echo "Skipping pip install -r requirements_all_ds.txt" ; fi

COPY . /app
COPY --from=frontend-builder /frontend/client/dist /app/client/dist

FROM ${APP_ENV}-server
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prod-server or dev-server


RUN chown -R redash /app
USER redash

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.PHONY: compose_build up test_db create_database clean down bundle tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash

compose_build:
docker-compose build
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build

up:
docker-compose up -d --build
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up -d

test_db:
@for i in `seq 1 5`; do \
Expand Down
15 changes: 12 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ version: '3.2'
# For a production example please refer to getredash/setup repository on GitHub.
services:
server:
build: .
build:
context: .
args:
APP_ENV: dev
command: dev_server
depends_on:
- postgres
Expand All @@ -22,7 +25,10 @@ services:
REDASH_MAIL_DEFAULT_SENDER: redash@example.com
REDASH_MAIL_SERVER: email
scheduler:
build: .
build:
context: .
args:
APP_ENV: dev
command: dev_scheduler
volumes:
- type: bind
Expand All @@ -35,7 +41,10 @@ services:
REDASH_MAIL_DEFAULT_SENDER: redash@example.com
REDASH_MAIL_SERVER: email
worker:
build: .
build:
context: .
args:
APP_ENV: dev
command: dev_worker
volumes:
- type: bind
Expand Down