build with dind
This commit is contained in:
parent
98af99de9f
commit
3fd71d0354
1 changed files with 10 additions and 4 deletions
|
|
@ -3,16 +3,22 @@ variables:
|
||||||
CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
|
CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
|
||||||
RAILS_ENV: "production"
|
RAILS_ENV: "production"
|
||||||
|
|
||||||
|
# Add this service
|
||||||
|
services:
|
||||||
|
- docker:20.10.16-dind
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- docker info
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
image: docker:20.10.16
|
||||||
script:
|
script:
|
||||||
- docker build -t $CONTAINER_IMAGE .
|
- docker build -t $CONTAINER_IMAGE .
|
||||||
- docker push $CONTAINER_IMAGE
|
- docker push $CONTAINER_IMAGE
|
||||||
|
|
@ -22,14 +28,17 @@ build:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
|
image: ruby:3.2.2
|
||||||
services:
|
services:
|
||||||
- postgres:latest
|
- postgres:latest
|
||||||
|
- docker:20.10.16-dind
|
||||||
variables:
|
variables:
|
||||||
POSTGRES_DB: "rails_test"
|
POSTGRES_DB: "rails_test"
|
||||||
POSTGRES_USER: "postgres"
|
POSTGRES_USER: "postgres"
|
||||||
POSTGRES_PASSWORD: "password"
|
POSTGRES_PASSWORD: "password"
|
||||||
DATABASE_URL: "postgresql://postgres:password@postgres:5432/rails_test"
|
DATABASE_URL: "postgresql://postgres:password@postgres:5432/rails_test"
|
||||||
script:
|
script:
|
||||||
|
- apt-get update -qq && apt-get install -y docker.io
|
||||||
- docker run --rm $CONTAINER_IMAGE bin/rails db:create db:migrate RAILS_ENV=test
|
- docker run --rm $CONTAINER_IMAGE bin/rails db:create db:migrate RAILS_ENV=test
|
||||||
- docker run --rm $CONTAINER_IMAGE bin/rails test
|
- docker run --rm $CONTAINER_IMAGE bin/rails test
|
||||||
only:
|
only:
|
||||||
|
|
@ -40,8 +49,5 @@ deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
script:
|
script:
|
||||||
- echo "Deploying to production..."
|
- echo "Deploying to production..."
|
||||||
# Add your deployment commands here
|
|
||||||
# For example, if using Kubernetes:
|
|
||||||
# - kubectl set image deployment/rails-app rails-app=$CONTAINER_IMAGE
|
|
||||||
only:
|
only:
|
||||||
- main
|
- main
|
||||||
Loading…
Add table
Add a link
Reference in a new issue