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"
|
||||
RAILS_ENV: "production"
|
||||
|
||||
# Add this service
|
||||
services:
|
||||
- docker:20.10.16-dind
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
before_script:
|
||||
- docker info
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: docker:20.10.16
|
||||
script:
|
||||
- docker build -t $CONTAINER_IMAGE .
|
||||
- docker push $CONTAINER_IMAGE
|
||||
|
|
@ -22,14 +28,17 @@ build:
|
|||
|
||||
test:
|
||||
stage: test
|
||||
image: ruby:3.2.2
|
||||
services:
|
||||
- postgres:latest
|
||||
- docker:20.10.16-dind
|
||||
variables:
|
||||
POSTGRES_DB: "rails_test"
|
||||
POSTGRES_USER: "postgres"
|
||||
POSTGRES_PASSWORD: "password"
|
||||
DATABASE_URL: "postgresql://postgres:password@postgres:5432/rails_test"
|
||||
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 test
|
||||
only:
|
||||
|
|
@ -40,8 +49,5 @@ deploy:
|
|||
stage: deploy
|
||||
script:
|
||||
- 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:
|
||||
- main
|
||||
- main
|
||||
Loading…
Add table
Add a link
Reference in a new issue