Skip to content

Commit

Permalink
chore(#502): 🧑‍💻 merge Dockerfiles
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Augustin <dev@andreas-augustin.org>
  • Loading branch information
AndreasAugustin committed Mar 16, 2024
1 parent 3dedc97 commit d815605
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 49 deletions.
26 changes: 23 additions & 3 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 @@ -56,11 +57,30 @@ jobs:
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: run tests
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
echo "Run tests"
container-structure-test test \
--image ${{ matrix.variant }}:${{ steps.meta.outputs.tags }} \
--config src/test-config.yaml
- 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
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
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"]
1 change: 0 additions & 1 deletion src/.dockerignore

This file was deleted.

32 changes: 0 additions & 32 deletions src/Dockerfile

This file was deleted.

0 comments on commit d815605

Please sign in to comment.