Skip to content

Commit f19f18a

Browse files
authored
Merge pull request #7 from wirwolf/master
Add Dockerfile and build by tags
2 parents fcf19d3 + 8d3d55b commit f19f18a

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
log
2+
venv
3+
.dockerignore
4+
.gitignore
5+
.gitlab-ci.yml.example

.github/workflows/release.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
push:
7+
branches:
8+
- 'master'
9+
tags:
10+
- '*'
11+
12+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
18+
jobs:
19+
build-and-push-image:
20+
runs-on: ubuntu-latest
21+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
22+
permissions:
23+
contents: read
24+
packages: write
25+
#
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
30+
- name: Log in to the Container registry
31+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
37+
- name: Extract metadata (tags, labels) for Docker
38+
id: meta
39+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
43+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
44+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
45+
- name: Build and push Docker image
46+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
47+
with:
48+
context: .
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
build-args: |
53+
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
54+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
55+
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM python:3.10
2+
3+
4+
###
5+
### Upgrade (install ps)
6+
###
7+
RUN set -eux \
8+
&& DEBIAN_FRONTEND=noninteractive apt update -qq \
9+
&& DEBIAN_FRONTEND=noninteractive apt install -qq -y --no-install-recommends --no-install-suggests \
10+
procps curl bash\
11+
&& apt autoclean \
12+
&& apt clean \
13+
&& true
14+
15+
###
16+
### Envs
17+
###
18+
ENV MY_USER="app" \
19+
MY_GROUP="app"
20+
21+
ARG DOCKER_UID=1000
22+
ARG DOCKER_GID=1000
23+
24+
###
25+
### User/Group
26+
###
27+
RUN set -eux \
28+
&& groupadd -g ${DOCKER_GID} -r ${MY_GROUP} \
29+
&& useradd -d /home/${MY_USER} -u ${DOCKER_UID} -m -s /bin/bash -g ${MY_GROUP} ${MY_USER} \
30+
&& true
31+
32+
33+
34+
RUN set -eux \
35+
&& DEBIAN_FRONTEND=noninteractive apt install -qq -y libpq-dev build-essential \
36+
&& true
37+
38+
COPY requirements.txt /requirements.txt
39+
40+
RUN pip install -r /requirements.txt
41+
42+
COPY . /app
43+
44+
WORKDIR /app/data
45+

0 commit comments

Comments
 (0)