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

chore(#502): 🧑‍💻 merge Dockerfiles #504

Merged
merged 10 commits into from
Mar 16, 2024
35 changes: 30 additions & 5 deletions .github/workflows/push_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
strategy:
matrix:
variant: ["actions-template-sync"]
target: ["prod", "dev"]

steps:
- name: checkout
Expand All @@ -53,14 +54,38 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
andyAugustin/${{ matrix.variant }}
ghcr.io/AndreasAugustin/${{ matrix.variant }}
andyaugustin/${{ matrix.variant }}
ghcr.io/andreasaugustin/${{ matrix.variant }}
tags: |
type=semver,pattern={{raw}},value=${{ inputs.tag }}
- name: Build and push ${{ matrix.variant }}
type=semver,pattern={{raw}},value=${{ inputs.tag }}${{ matrix.target == 'dev' && '-dev' || '' }}
- name: Build ${{ matrix.variant }}
uses: docker/build-push-action@v5
with:
context: ./src/
context: .
target: ${{ matrix.target }}
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: install container test tools
run: |
echo "Install container tools"
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 \
&& chmod +x container-structure-test-linux-amd64 \
&& sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
- name: test docker image
run: |
echo "Run tests"
container-structure-test test \
--image andyaugustin/${{ matrix.variant }}:${{ inputs.tag }}${{ matrix.target == 'dev' && '-dev' || '' }}\
--config docker-test-config.yml
container-structure-test test \
--image ghcr.io/andreasaugustin/${{ matrix.variant }}:${{ inputs.tag }}${{ matrix.target == 'dev' && '-dev' || '' }}\
--config docker-test-config.yml
- name: push ${{ matrix.variant }}
uses: docker/build-push-action@v5
with:
context: .
target: ${{ matrix.target }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_test_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ jobs:
echo "Run tests"
container-structure-test test \
--image ${{ matrix.docker-image }}:${{ inputs.tag }} \
--config src/test-config.yaml
--config docker-test-config.yml
43 changes: 33 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
########################################
# prod image
#######################################
# image for dev build environment
######################################
FROM alpine:3.19.1 as dev
FROM alpine:3.19.1 as prod

ARG GH_CLI_VER=2.44.1

# TODO(anau) change user
ARG GITHUB_URL="https://github.com/AndreasAugustin/actions-template-sync"

# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
LABEL org.opencontainers.image.url="${GITHUB_URL}"
LABEL org.opencontainers.image.documentation="${GITHUB_URL}/README.md"
LABEL org.opencontainers.image.source="${GITHUB_URL}"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.authors="andyAugustin"
LABEL org.opencontainers.image.title="actions-template-sync image"
LABEL org.opencontainers.image.description="contains actions-template-sync"

# install packages
RUN apk add --update --no-cache bash make git zsh curl tmux musl openssh git-lfs vim yq gnupg tig
RUN apk add --update --no-cache bash git curl musl openssh git-lfs yq gnupg

RUN wget https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_386.tar.gz -O ghcli.tar.gz
RUN tar --strip-components=1 -xf ghcli.tar.gz

# Make zsh your default shell for tmux
RUN echo "set-option -g default-shell /bin/zsh" >> /root/.tmux.conf

# install oh-my-zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

ADD src/*.sh /bin/
RUN chmod +x /bin/entrypoint.sh \
&& chmod +x /bin/sync_template.sh \
Expand All @@ -26,8 +32,25 @@ RUN chmod +x /bin/entrypoint.sh \
RUN mkdir -p /root/.ssh \
&& ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts

ENTRYPOINT ["/bin/bash", "/bin/entrypoint.sh"]
#######################################
# image for dev build environment
######################################
FROM prod as dev

# install packages
RUN apk add --update --no-cache make zsh tmux vim tig

# Make zsh your default shell for tmux
RUN echo "set-option -g default-shell /bin/zsh" >> /root/.tmux.conf

# install oh-my-zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

WORKDIR /app

ENTRYPOINT ["/bin/zsh"]

#######################################
# image for creating the documentation
######################################
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ markdownlint: ## Validate markdown files

.PHONY: zsh
zsh: ## open dev container with build environment
docker-compose run --service-ports dev /bin/zsh
docker-compose run --service-ports dev

.PHONY: prod
prod: ## run the prod docker image with bash
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ There are other great tools available within GitHub. Here you can find a compari
| ignore files | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
| creates a PR | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: |
| sign commits | :heavy_check_mark: | :x: | :x: | :x: |
| docker images available | :heavy_check_mark: | :x: | :x: | :x: |
| remarks | The action is placed within the target repositories | The action is placed within the target repositories | CLI meant for local use | The action will be based within the base repository with a list of dependent repositories |

## DEV
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.7'
version: "3.7"

services:
dev:
Expand Down Expand Up @@ -26,6 +26,7 @@ services:

prod:
build:
context: ./src/
context: .
target: prod
tty: true
entrypoint: ["/bin/bash"]
File renamed without changes.
1 change: 0 additions & 1 deletion src/.dockerignore

This file was deleted.

32 changes: 0 additions & 32 deletions src/Dockerfile

This file was deleted.