Skip to content

Commit 4a76b2c

Browse files
authored
Build Docker image on release (#123)
1 parent 907af48 commit 4a76b2c

File tree

3 files changed

+69
-14
lines changed

3 files changed

+69
-14
lines changed

.github/workflows/docker.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: docker
2+
3+
on: [push, workflow_dispatch]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-22.04
8+
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Build Docker image
13+
run: sudo docker build .
14+
working-directory: backend
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
36+
- name: Build and push Docker image
37+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
38+
with:
39+
context: .
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}

backend/Dockerfile

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
FROM ubuntu:22.04
1+
FROM python:3.10-alpine3.17
2+
ARG packages
3+
RUN apk --update add ${packages} \
4+
&& rm -rf /var/cache/apk/* \
5+
&& pip3 install --upgrade pip pipenv wheel virtualenv
26

3-
RUN apt-get update -y && \
4-
apt-get upgrade -y && \
5-
apt-get install -y python3 python3-pip
7+
COPY . /app
8+
WORKDIR /app
69

7-
RUN useradd -ms /bin/bash bracket
8-
WORKDIR /home/bracket/backend
9-
10-
COPY . /home/bracket/backend
11-
RUN chown -R bracket:bracket /home/bracket
10+
# -- Install dependencies:
11+
RUN addgroup -S bracket && adduser -S bracket -G bracket \
12+
&& chown -R bracket:bracket /app
1213
USER bracket
13-
ENV PATH="${PATH}:/home/bracket/.local/bin"
1414

15-
# Install backend
16-
RUN python3 -m pip install --upgrade pipenv wheel virtualenv
17-
RUN pipenv install -d
18-
RUN pipenv run mypy .
15+
RUN set -ex \
16+
&& pip3 install --upgrade pip pipenv wheel virtualenv \
17+
&& pipenv install --deploy

0 commit comments

Comments
 (0)