Skip to content

Commit

Permalink
#448 Use python image in drone (#465)
Browse files Browse the repository at this point in the history
* #448  Improve deps code for nodejs image

* #448  Revert node's image and drone workspaces switching

* #448  Use python image in tests

* #448  Use python image in tests#2

* #448  Drone build python-dev with pull_request too

* #448  Fix python-prod building
  • Loading branch information
duker33 authored Aug 2, 2018
1 parent 4db19ac commit 1a0e0f0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 40 deletions.
47 changes: 15 additions & 32 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,9 @@ workspace:


pipeline:
# @todo #352:60m Use ready image for python in drone. stb2
# - rm pip-install step
# - refactor test step
# - rm/modify docker-build step
pip-install:
image: python
commands:
- pip install -r requirements.txt
- rm -rf /usr/app/deps/site-packages
- mv /usr/local/lib/python3.6/site-packages /drone/deps
when:
event: [push, pull_request]

nodejs-build: # with `npm install` inside
image: docker/compose:1.22.0
environment:
- DEPS_DIR=/drone/deps
commands:
- cd docker/
- cp drone_env/.env . && cp drone_env/* env_files/
Expand All @@ -38,16 +24,27 @@ pipeline:
gulp-build:
image: fidals/se-nodejs:dev
environment:
- DEPS_DIR=/drone/deps
# deps from nodejs image
- DEPS_DIR=/usr/app/deps
commands:
- cd /usr/app/src/
- cp -r /usr/app/src/node_modules .
- gulp build
- cp -r front_build/ /drone/shopelectro
when:
event: [push, pull_request]

python-build:
image: docker/compose:1.22.0
commands:
- cd docker/
# Build python images with sources and static files
- docker-compose -f docker-compose-build.yml build python-dev python-prod
volumes:
- /var/run/docker.sock:/var/run/docker.sock
when:
event: [push, pull_request]

test:
image: python
image: fidals/se:dev
environment:
- TEST_ENV=true
- DJANGO_SETTINGS_MODULE=shopelectro.settings.drone
Expand All @@ -67,7 +64,6 @@ pipeline:
- SELENIUM_TIMEOUT_SECONDS=180
- SELENIUM_WAIT_SECONDS=180
commands:
- cp -r /drone/deps/* /usr/local/lib/python3.6/site-packages
- python manage.py migrate
- python manage.py excel
- python manage.py price
Expand Down Expand Up @@ -103,19 +99,6 @@ pipeline:
when:
event: pull_request

docker-build:
image: docker/compose:1.17.1
environment:
- DEPS_DIR=/drone/deps
commands:
- cd docker
# Build python images with sources and static files
- docker-compose -f docker-compose-build.yml build --no-cache python-dev python-prod
volumes:
- /var/run/docker.sock:/var/run/docker.sock
when:
event: push

docker-push:
image: docker:latest
environment:
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ services:
image: fidals/se-nodejs:dev
build:
context: ../
args:
- deps_dir=$DEPS_DIR
dockerfile: docker/images/node/Dockerfile

nginx:
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ services:
#- ../gulpfile.babel.js:/usr/app/src/gulpfile.babel.js
- ../front:/usr/app/src/front
- ../front_build:/usr/app/src/front_build
# @todo #457:15m Return back refarm deps to nodejs service.

# Uncomment next line if you dev refarm-site's front
# - ../../refarm-site/:$DEPS_DIR/
env_file:
Expand Down
5 changes: 2 additions & 3 deletions docker/images/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM node:slim

ARG deps_dir
ENV DEPS_DIR=$deps_dir
ENV DEPS_DIR=/usr/app/deps

WORKDIR /usr/app/src/

Expand All @@ -26,4 +25,4 @@ RUN npm install --no-optional
RUN gulp build

# Keeps track of changes if static files are built, otherwise builds them
CMD bash -c "[ '$(ls -A /usr/app/src/build)' ] && gulp watch || (gulp build && gulp watch)"
CMD bash -c "[ '$(ls -A /usr/app/src/front_build)' ] && gulp watch || (gulp build && gulp watch)"
2 changes: 1 addition & 1 deletion docker/images/python/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ COPY ./etc/gunicorn.py /etc/
# See npm section of `.drone.yml` file
COPY ./front_build ./front_build
# built frontend files are required
RUN /bin/bash -c '[ "$(ls -A front/build)" ] || exit 1'
RUN /bin/bash -c '[ "$(ls -A front_build)" ] || exit 1'

2 comments on commit 1a0e0f0

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 1a0e0f0 Aug 2, 2018

Choose a reason for hiding this comment

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

Puzzle 352-4d0775ee disappeared from .drone.yml, that's why I closed #448. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 1a0e0f0 Aug 2, 2018

Choose a reason for hiding this comment

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

Puzzle 457-1bf03782 disappeared from docker/docker-compose.yml, that's why I closed #464. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.