Added CodeBuild files and update snibox to latest

This commit is contained in:
Pavel Pivovarov
2019-03-16 01:16:44 +00:00
parent b9253ee6e6
commit 611e5c6029
5 changed files with 65 additions and 3 deletions

View File

@@ -5,3 +5,5 @@ Dockerfile
README.md
docker-compose.yml
snibox.sh
build_container.yml
upload_image.yml

View File

@@ -1,4 +1,4 @@
FROM ruby:2.5-alpine
FROM ruby:2.6-alpine
RUN apk add --no-cache \
git \
@@ -12,7 +12,7 @@ RUN apk add --no-cache \
WORKDIR /app
ENV GIT_HASH 82a2fa3ca1038b1c9defc77b3132a511daa7592f
ENV GIT_HASH fe586f4653e337f84cbb4116d0c5887f67268569
ENV RAILS_ENV development
ENV RACK_ENV development

View File

@@ -5,7 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end
ruby '~> 2.5.1'
ruby '>= 2.5.0', '< 2.7.0'
gem 'rails', '~> 5.2', '>=5.2.2'
gem 'pg', '~> 1.0'

31
build_container.yml Normal file
View File

@@ -0,0 +1,31 @@
---
version: 0.2
env:
variables:
ECR: 724284355692.dkr.ecr.$AWS_REGION.amazonaws.com
phases:
pre_build:
commands:
- echo "Evaluate environment"
- DATE=$(date +%Y%m%d)
- IMAGE="snibox-sqlite"
- echo -n $DATE > tag.txt
- echo "Logging to docker"
- aws ecr get-login --region $AWS_REGION --no-include-email | bash
build:
commands:
- echo "Building $ECR/$IMAGE:$DATE"
- docker build -t $ECR/$IMAGE:$DATE .
post_build:
commands:
- echo "Uploading docker image"
- docker push $ECR/$IMAGE:$DATE
- echo "Generating image definition"
- printf '[{"name":"snibox-sqlite","imageUri":"%s"}]' $ECR/$IMAGE:$DATE > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json
- tag.txt

29
upload_image.yml Normal file
View File

@@ -0,0 +1,29 @@
---
version: 0.2
env:
variables:
USER: snowmean
ECR: 724284355692.dkr.ecr.$AWS_REGION.amazonaws.com
parameter-store:
PASSWD: "docker_password"
phases:
pre_build:
commands:
- echo "Evaluating environment"
- TAG=$(cat tag.txt)
- IMAGE="snibox-sqlite"
build:
commands:
- echo "Logging to ECR"
- aws ecr get-login --region $AWS_REGION --no-include-email | bash
- echo "Download ECR image"
- docker pull $ECR/$IMAGE:$TAG
- echo "Updating tags"
- docker tag $ECR/$IMAGE:$TAG $USER/$IMAGE:$TAG
- docker tag $USER/$IMAGE:$TAG $USER/$IMAGE:latest
- echo "Logging to Docker Hub"
- docker login -u $USER -p $PASSWD
- docker push $USER/$IMAGE:$TAG
- docker push $USER/$IMAGE:latest