-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a docker image that can be used to deploy CIVIFORM to aws and …
…azure (#406) Co-authored-by: dkatzz <86739416+dkatzz@users.noreply.github.com>
- Loading branch information
1 parent
46fa72e
commit 7d0f519
Showing
4 changed files
with
515 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: build_push_development_env_image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
# Setting this enables manually triggering workflow in the GitHub UI | ||
# see https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow | ||
workflow_dispatch: {} | ||
|
||
permissions: read-all | ||
|
||
# Build and push the deployment env image. | ||
jobs: | ||
build_deployment_env: | ||
runs-on: ubuntu-latest | ||
|
||
concurrency: | ||
group: build-${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
name: Build deployment env | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
- id: file_changes | ||
uses: tj-actions/changed-files@v45 | ||
with: | ||
json: 'true' | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Run build | ||
id: build_and_push_deployment_env | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
PLATFORM: 'linux/amd64' | ||
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
if: contains(toJSON(steps.file_changes.outputs.all_changed_files), 'cloud/aws/deployment/') | ||
run: | | ||
cd $GITHUB_WORKSPACE/cloud/aws/deployment | ||
./build-deployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Builds the deployment environment Docker image | ||
|
||
set -e | ||
set +x | ||
|
||
readonly SHORT_SHA="$(git rev-parse --short HEAD)" | ||
readonly DATE_IN_UNIX_SECONDS="$(date +%s)" | ||
readonly SNAPSHOT_TAG="SNAPSHOT-${SHORT_SHA}-${DATE_IN_UNIX_SECONDS}" | ||
readonly IMAGE="deployment-env" | ||
|
||
PLATFORM_ARG=() | ||
if [[ -n "${PLATFORM}" ]]; then | ||
PLATFORM_ARG=(--platform "${PLATFORM}") | ||
fi | ||
readonly PLATFORM_ARG | ||
|
||
echo "start ${IMAGE} build" | ||
docker buildx create --use | ||
docker buildx build --push \ | ||
"${PLATFORM_ARG[@]}" \ | ||
-t "docker.io/civiform/${IMAGE}:latest" \ | ||
-t "docker.io/civiform/${IMAGE}:${SNAPSHOT_TAG}" \ | ||
-f development.Dockerfile . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu | ||
|
||
RUN wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | tee /usr/share/keyrings/hashicorp-archive-keyring.gpg | ||
RUN echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list | ||
|
||
# Install tool dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
terraform \ | ||
python3-pip \ | ||
curl \ | ||
unzip \ | ||
python3.10-venv \ | ||
default-jre \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -rf /var/lib/apt/lists.d/* \ | ||
&& apt-get autoremove \ | ||
&& apt-get clean \ | ||
&& apt-get autoclean | ||
|
||
# Install AWS CLI | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | ||
RUN unzip awscliv2.zip && ./aws/install | ||
|
||
# Install Azure CLI | ||
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash | ||
|
||
# Install Docker-In-Docker | ||
# Following the guide found here: | ||
# https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md | ||
COPY library-scripts/*.sh /tmp/library-scripts/ | ||
ENV DOCKER_BUILDKIT=1 | ||
RUN apt-get update && /bin/bash /tmp/library-scripts/docker-in-docker-debian.sh | ||
ENTRYPOINT ["/usr/local/share/docker-init.sh"] | ||
VOLUME [ "/var/lib/docker" ] | ||
|
||
# Start the a shell in the container, this image needs to be started with the following options | ||
# --init --privileged -it | ||
CMD ["bash"] | ||
|
||
# Alternatively we could make the image sleep forever and then the user can connect into the | ||
# running container. | ||
# CMD ["sleep", "infinity"] |
Oops, something went wrong.