Skip to content

Commit f1de9a0

Browse files
Merge pull request #40 from Tecnativa/migrate-to-template
Apply image template
2 parents 74c627b + 49c962b commit f1de9a0

File tree

6 files changed

+262
-160
lines changed

6 files changed

+262
-160
lines changed

.copier-answers.image-template.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Changes here will be overwritten by Copier; do NOT edit manually
2+
_commit: v0.1.2
3+
_src_path: https://github.com/Tecnativa/image-template.git
4+
dockerhub_image: tecnativa/docker-socket-proxy
5+
image_platforms:
6+
- linux/386
7+
- linux/amd64
8+
- linux/arm/v6
9+
- linux/arm/v7
10+
- linux/arm/v8
11+
- linux/arm64
12+
- linux/ppc64le
13+
- linux/s390x
14+
main_branches:
15+
- master
16+
project_name: docker-socket-proxy
17+
project_owner: Tecnativa
18+
push_to_ghcr: true
19+
pytest: true
20+
python_versions:
21+
- "3.8"

.github/workflows/ci.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Build, Test & Deploy
2+
3+
"on":
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
workflow_dispatch:
9+
inputs:
10+
pytest_addopts:
11+
description:
12+
Extra options for pytest; use -vv for full details; see
13+
https://docs.pytest.org/en/latest/example/simple.html#how-to-change-command-line-options-defaults
14+
required: false
15+
16+
env:
17+
LANG: "en_US.utf-8"
18+
LC_ALL: "en_US.utf-8"
19+
PIP_CACHE_DIR: ${{ github.workspace }}/.cache.~/pip
20+
PIPX_HOME: ${{ github.workspace }}/.cache.~/pipx
21+
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache.~/pypoetry
22+
POETRY_VIRTUALENVS_IN_PROJECT: "true"
23+
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
24+
PYTHONIOENCODING: "UTF-8"
25+
26+
jobs:
27+
build-test:
28+
runs-on: ubuntu-20.04
29+
strategy:
30+
matrix:
31+
python:
32+
- 3.8
33+
steps:
34+
# Prepare environment
35+
- uses: actions/checkout@v2
36+
# Set up and run tests
37+
- name: Install python
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ matrix.python }}
41+
- name: Generate cache key CACHE
42+
run:
43+
echo "CACHE=${{ secrets.CACHE_DATE }} ${{ runner.os }} $(python -VV |
44+
sha256sum | cut -d' ' -f1) ${{ hashFiles('pyproject.toml') }} ${{
45+
hashFiles('poetry.lock') }}" >> $GITHUB_ENV
46+
- uses: actions/cache@v2
47+
with:
48+
path: |
49+
.cache.~
50+
.venv
51+
~/.local/bin
52+
key: venv ${{ env.CACHE }}
53+
- run: pip install poetry
54+
- name: Patch $PATH
55+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
56+
- run: poetry install
57+
# Run tests
58+
- run: poetry run pytest --prebuild
59+
build-push:
60+
runs-on: ubuntu-20.04
61+
services:
62+
registry:
63+
image: registry:2
64+
ports:
65+
- 5000:5000
66+
env:
67+
DOCKER_IMAGE_NAME: ${{ github.repository }}
68+
DOCKERHUB_IMAGE_NAME: tecnativa/docker-socket-proxy
69+
PUSH: ${{ toJSON(github.event_name != 'pull_request') }}
70+
steps:
71+
# Set up Docker Environment
72+
- uses: actions/checkout@v2
73+
- uses: actions/cache@v2
74+
with:
75+
path: |
76+
/tmp/.buildx-cache
77+
key: buildx|${{ secrets.CACHE_DATE }}|${{ runner.os }}
78+
- name: Set up QEMU
79+
uses: docker/setup-qemu-action@v1
80+
- name: Set up Docker Buildx
81+
id: buildx
82+
uses: docker/setup-buildx-action@v1
83+
with:
84+
driver-opts: network=host
85+
install: true
86+
# Build and push
87+
- name: Docker meta for local images
88+
id: docker_meta_local
89+
uses: crazy-max/ghaction-docker-meta@v1
90+
with:
91+
images: localhost:5000/${{ env.DOCKER_IMAGE_NAME }}
92+
tag-edge: true
93+
tag-semver: |
94+
{{version}}
95+
{{major}}
96+
{{major}}.{{minor}}
97+
- name: Build and push to local (test) registry
98+
uses: docker/build-push-action@v2
99+
with:
100+
context: .
101+
file: ./Dockerfile
102+
platforms: |
103+
linux/386
104+
linux/amd64
105+
linux/arm/v6
106+
linux/arm/v7
107+
linux/arm/v8
108+
linux/arm64
109+
linux/ppc64le
110+
linux/s390x
111+
load: false
112+
push: true
113+
cache-from: type=local,src=/tmp/.buildx-cache
114+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
115+
labels: ${{ steps.docker_meta_local.outputs.labels }}
116+
tags: ${{ steps.docker_meta_local.outputs.tags }}
117+
# Next jobs only happen outside of pull requests and on main branches
118+
- name: Login to DockerHub
119+
if: ${{ fromJSON(env.PUSH) }}
120+
uses: docker/login-action@v1
121+
with:
122+
username: ${{ secrets.DOCKERHUB_LOGIN }}
123+
password: ${{ secrets.DOCKERHUB_TOKEN }}
124+
- name: Login to GitHub Container Registry
125+
if: ${{ fromJSON(env.PUSH) }}
126+
uses: docker/login-action@v1
127+
with:
128+
registry: ghcr.io
129+
username: ${{ secrets.BOT_LOGIN }}
130+
password: ${{ secrets.BOT_TOKEN }}
131+
- name: Docker meta for public images
132+
if: ${{ fromJSON(env.PUSH) }}
133+
id: docker_meta_public
134+
uses: crazy-max/ghaction-docker-meta@v1
135+
with:
136+
images: |
137+
ghcr.io/${{ env.DOCKER_IMAGE_NAME }}
138+
${{ env.DOCKERHUB_IMAGE_NAME }}
139+
tag-edge: true
140+
tag-semver: |
141+
{{version}}
142+
{{major}}
143+
{{major}}.{{minor}}
144+
- name: Build and push to public registry(s)
145+
if: ${{ fromJSON(env.PUSH) }}
146+
uses: docker/build-push-action@v2
147+
with:
148+
context: .
149+
file: ./Dockerfile
150+
platforms: |
151+
linux/386
152+
linux/amd64
153+
linux/arm/v6
154+
linux/arm/v7
155+
linux/arm/v8
156+
linux/arm64
157+
linux/ppc64le
158+
linux/s390x
159+
load: false
160+
push: true
161+
cache-from: type=local,src=/tmp/.buildx-cache
162+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
163+
labels: ${{ steps.docker_meta_public.outputs.labels }}
164+
tags: ${{ steps.docker_meta_public.outputs.tags }}

.github/workflows/test.yaml

Lines changed: 0 additions & 111 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![Last image-template](https://img.shields.io/badge/last%20template%20update-v0.1.2-informational)](https://github.com/Tecnativa/image-template/tree/v0.1.2)
2+
[![GitHub Container Registry](https://img.shields.io/badge/GitHub%20Container%20Registry-latest-%2324292e)](https://github.com/orgs/Tecnativa/packages/container/package/docker-socket-proxy)
3+
[![Docker Hub](https://img.shields.io/badge/Docker%20Hub-latest-%23099cec)](https://hub.docker.com/r/tecnativa/docker-socket-proxy)
4+
15
# Docker Socket Proxy
26

37
[![Docker Hub](https://img.shields.io/badge/Docker%20Hub-docker.io%2Ftecnativa%2Fdocker--socket--proxy-%23099cec)](https://hub.docker.com/r/tecnativa/docker-socket-proxy)

0 commit comments

Comments
 (0)