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

add aws-cli-php #1016

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
sudo mv ./hub-tool/hub-tool /usr/local/bin

expect -c "
set timeout 5
set timeout 10
spawn env hub-tool login ${DOCKER_REGISTRY_USERNAME}
expect \"Password:\"
send \"${DOCKER_REGISTRY_PASSWORD}\n\"
Expand All @@ -185,7 +185,6 @@ jobs:
- run:
name: update manifest
command: |
make ci:diff
make ci:diff | while read DIR; do
if [[ -e "$CIRCLECI_WORKSPACE/$DIR/Dockerfile.arm64" ]] && [[ -e "$CIRCLECI_WORKSPACE/$DIR/Dockerfile" ]] ; then
cd ${CIRCLECI_WORKSPACE}/${DIR};
Expand Down
25 changes: 25 additions & 0 deletions aws-cli-php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG AWS_CLI_VERSION=2.3.5
ARG PHP_VERSION=8.0

FROM amazon/aws-cli:${AWS_CLI_VERSION}

ARG PHP_VERSION
ARG AWS_CLI_VERSION

LABEL version="${AWS_CLI_VERSION}-${PHP_VERSION}"
LABEL aws_cli_version="${AWS_CLI_VERSION}"
LABEL php_version="${PHP_VERSION}"
LABEL maintainer="[email protected]"

RUN amazon-linux-extras enable php${PHP_VERSION} \
&& yum install -y \
jq \
git \
php \
php-mbstring \
php-gmp \
php-mcrypt \
php-xml \
&& yum clean all

ENTRYPOINT ['/usr/local/bin/aws']
25 changes: 25 additions & 0 deletions aws-cli-php/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG AWS_CLI_VERSION=2.3.5
ARG PHP_VERSION=8.0

FROM amazon/aws-cli:${AWS_CLI_VERSION}

ARG PHP_VERSION
ARG AWS_CLI_VERSION

LABEL version="${AWS_CLI_VERSION}-${PHP_VERSION}"
LABEL aws_cli_version="${AWS_CLI_VERSION}"
LABEL php_version="${PHP_VERSION}"
LABEL maintainer="[email protected]"

RUN amazon-linux-extras enable php${PHP_VERSION} \
&& yum install -y \
jq \
git \
php \
php-mbstring \
php-gmp \
php-mcrypt \
php-xml \
&& yum clean all

ENTRYPOINT ['/usr/local/bin/aws']
87 changes: 87 additions & 0 deletions aws-cli-php/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
ARCH:=$(shell uname -m)
ENV:="prod"
LATEST_TAG:=$(shell if [ $(ENV) = "prod" ]; then \
echo "latest"; \
else \
echo "$(ENV)"; \
fi)
SCOPE_SUFFIX:=$(shell if [ $(ENV) = "prod" ]; then \
echo ""; \
else \
echo "-$(ENV)"; \
fi)
EXTENSION:=$(shell case "$(ARCH)" in \
("arm64"|"aarch64") echo ".arm64" ;; \
("x86_64") echo "" ;; \
(*) echo $(ARCH) ;; \
esac)

.PHONY: build
build:
@find . -type f -name "Dockerfile${EXTENSION}" | while read -r FILE; do \
docker build -f Dockerfile -t chatwork/`basename $$PWD` .; \
version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/`basename $$PWD`:latest); \
aws_cli_version=$$(docker inspect -f {{.Config.Labels.aws_cli_version}} chatwork/`basename $$PWD`:latest); \
php_version=$$(docker inspect -f {{.Config.Labels.php_version}} chatwork/`basename $$PWD`:latest); \
if [ -n "$$version" ] && [ -n "$$aws_cli_version" ] && [ -n "$$php_version" ]; then \
docker tag chatwork/`basename $$PWD`:latest chatwork/`basename $$PWD`:$$version; \
fi \
done

.PHONY: check
check:
@version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/`basename $$PWD`:latest); \
aws_cli_version=$$(docker inspect -f {{.Config.Labels.aws_cli_version}} chatwork/`basename $$PWD`:latest); \
php_version=$$(docker inspect -f {{.Config.Labels.php_version}} chatwork/`basename $$PWD`:latest); \
if [[ -z $$version ]]; then \
echo "\033[91mError: version is not defined in Dockerfile.\033[0m"; \
exit 1; \
fi; \
if [[ -z $$aws_cli_version ]]; then \
echo "\033[91mError: aws_cli_version is not defined in Dockerfile.\033[0m"; \
exit 1; \
fi; \
if [[ -z $$php_version ]]; then \
echo "\033[91mError: php_version is not defined in Dockerfile.\033[0m"; \
exit 1; \
fi; \
echo "\033[92mno problem.\033[0m";

.PHONY: test
test:
docker-compose -f docker-compose.test.yml up --build --no-start sut
docker cp $(shell pwd)/goss `basename $$PWD`:/goss
docker-compose -f docker-compose.test.yml up --no-recreate --exit-code-from sut sut

.PHONY: push
push:
@version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/`basename $$PWD`:latest); \
if docker inspect --format='{{index .RepoDigests 0}}' chatwork/$$(basename $$PWD):$$version >/dev/null 2>&1; then \
echo "no changes"; \
else \
docker tag chatwork/`basename $$PWD`:latest chatwork/`basename $$PWD`:$$version-$(ARCH)$(SCOPE_SUFFIX); \
docker push chatwork/`basename $$PWD`:$$version-$(ARCH)$(SCOPE_SUFFIX); \
fi

.PHONY: manifest\:push
manifest\:push:
@version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/`basename $$PWD`:latest); \
if docker inspect --format='{{index .RepoDigests 0}}' chatwork/$$(basename $$PWD):$$version >/dev/null 2>&1; then \
echo "no changes"; \
else \
docker pull chatwork/`basename $$PWD`:$$version-aarch64$(SCOPE_SUFFIX); \
docker pull chatwork/`basename $$PWD`:$$version-x86_64$(SCOPE_SUFFIX); \
arm64_digest=$$(docker inspect -f '{{index .RepoDigests 0}}' chatwork/`basename $$PWD`:$$version-aarch64$(SCOPE_SUFFIX)); \
amd64_digest=$$(docker inspect -f '{{index .RepoDigests 0}}' chatwork/`basename $$PWD`:$$version-x86_64$(SCOPE_SUFFIX)); \
docker buildx imagetools create -t chatwork/`basename $$PWD`:$$version$(SCOPE_SUFFIX) $$arm64_digest $$amd64_digest; \
docker buildx imagetools create -t chatwork/`basename $$PWD`:$(LATEST_TAG) $$arm64_digest $$amd64_digest; \
hub-tool tag rm chatwork/`basename $$PWD`:$$version-aarch64$(SCOPE_SUFFIX) -f; \
hub-tool tag rm chatwork/`basename $$PWD`:$$version-x86_64$(SCOPE_SUFFIX) -f; \
fi

.PHONY: manifest\:succeed-message
manifest\:succeed-message:
@version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/aws-cli-php:latest); \
echo "Released new tags."; \
echo "- chatwork/aws-cli-php:$$version$(SCOPE_SUFFIX)"; \
echo "- chatwork/aws-cli-php:$(LATEST_TAG)";
9 changes: 9 additions & 0 deletions aws-cli-php/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# aws-cli-php

aws-cli-php is an image of [aws-cli](https://hub.docker.com/r/amazon/aws-cli) with php

## Usage

```
$ docker run -it chatwork/aws-cli-php help
```
20 changes: 20 additions & 0 deletions aws-cli-php/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'
services:
aws-cli-php:
build:
context: .
image: chatwork/aws-cli-php
entrypoint: /bin/bash
sut:
image: chatwork/dgoss:latest
environment:
GOSS_FILES_PATH: /goss
GOSS_FILES_STRATEGY: cp
entrypoint: ""
command: /usr/local/bin/dgoss run --entrypoint "" chatwork/aws-cli-php tail -f /dev/null
container_name: aws-cli-php
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./goss/goss.yaml:/goss/goss.yaml
depends_on:
- aws-cli-php
8 changes: 8 additions & 0 deletions aws-cli-php/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
command:
php -v:
exit-status: 0
stdout:
- "/^PHP 8.[0-9]+/"

aws help:
exit-status: 0
Empty file added aws-cli-php/hooks/test
Empty file.
4 changes: 4 additions & 0 deletions aws-cli-php/variant.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
awscli:
version: 2.3.5
previousVersion: 2.3.4
18 changes: 18 additions & 0 deletions aws-cli-php/variant.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
provisioners:
textReplace:
Dockerfile:
from: "ARG AWS_CLI_VERSION={{ .awscli.previousVersion }}"
to: "ARG AWS_CLI_VERSION={{ .awscli.version }}"
Dockerfile.arm64:
from: "ARG AWS_CLI_VERSION={{ .awscli.previousVersion }}"
to: "ARG AWS_CLI_VERSION={{ .awscli.version }}"
goss/goss.yaml:
from: "- {{ .awscli.previousVersion }}"
to: "- {{ .awscli.version }}"

dependencies:
aws-cli:
releasesFrom:
dockerImageTags:
source: amazon/aws-cli
version: "> 2.3.5"