Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
flounderpinto committed Jan 22, 2024
1 parent 8b5adcf commit d2dddb1
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/workflow-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker build branch
run: make docker
if: ${{ github.ref_type == 'branch' && github.ref_name != 'main' }}

- name: Docker build main
run: make docker_main
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}

- name: Docker build tag
run: make docker_tag TAG="${{github.ref_name}}"
if: ${{ github.ref_type == 'tag' }}
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

CONTAINER_CODE_DIR=/opt/code

DOCKER_REGISTRY=index.docker.io/flounderpinto

DOCKER_REPO=quicktype
DOCKER_BUILD_BRANCH_CMD=dockerBuildStandardBranch -r ${DOCKER_REPO} ${ARGS}
DOCKER_BUILD_MAIN_CMD=dockerBuildStandardMain -r ${DOCKER_REPO} ${ARGS}
DOCKER_BUILD_TAG_CMD=dockerBuildStandardTag ${TAG} -r ${DOCKER_REPO} ${ARGS}
DOCKER_BUILDER_IMAGE=${DOCKER_REGISTRY}/builder-docker-flounderpinto:v0.1.0
DOCKER_BUILDER_PULL_CMD=docker pull ${DOCKER_BUILDER_IMAGE}
DOCKER_BUILDER_RUN_CMD=${DOCKER_BUILDER_PULL_CMD} && \
docker run \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${HOME}/.docker:/tmp/.docker:ro \
-v ${ROOT_DIR}:${CONTAINER_CODE_DIR} \
${DOCKER_BUILDER_IMAGE}

.PHONY: docker docker_main docker_tag

docker:
${DOCKER_BUILDER_RUN_CMD} ${DOCKER_BUILD_BRANCH_CMD}

docker_main:
${DOCKER_BUILDER_RUN_CMD} ${DOCKER_BUILD_MAIN_CMD}

docker_tag:
test ${TAG}
${DOCKER_BUILDER_RUN_CMD} ${DOCKER_BUILD_TAG_CMD}

#Everything right of the pipe is order-only prerequisites.
all: | docker
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# quicktype-docker
# quicktype-docker

A docker image of https://github.com/glideapps/quicktype
19 changes: 19 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update && \
apt install -y \
curl && \
curl -sL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh && \
chmod 755 /tmp/nodesource_setup.sh && \
/tmp/nodesource_setup.sh && \
apt install -y \
nodejs && \
npm install -g quicktype && \
apt remove -y \
curl && \
apt autoremove -y && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["quicktype"]
17 changes: 17 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

#If this container is run as a user, then home will be set to "/".
# Set the home directory env variable to the home directory created in the Dockerfile.
if [ "${HOME}" = "/" ]; then
export HOME="$USER_HOME"
fi

#Set the container id of this container.
# Often the short version of this is set in HOSTNAME,
# but when using "--network host", HOSTNAME is set to the hostname of the host,
# so something else is needed.
export CONTAINER_ID=$(basename $(cat /proc/1/cpuset))

echo "Running..."
exec "${@}"
echo "...done"

0 comments on commit d2dddb1

Please sign in to comment.