Skip to content

Commit

Permalink
Create docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
Eve-ning committed Apr 1, 2024
1 parent ce9e15f commit f3bd66a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 13 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-ls-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Create and publish our custom Label Studio Docker image
on:
push:
branches: [ 'terraform' ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# 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.
# 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.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ./src/terraform
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
36 changes: 23 additions & 13 deletions src/terraform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,30 @@ RUN pip3 install label-studio
# to the host machine. You need to do that manually
EXPOSE 8080

ARG POSTGRE_PASSWORD
ARG POSTGRE_USER
ARG POSTGRE_HOST

# Assert that the POSTGRE_PASSWORD and POSTGRE_USER
RUN test -n "$POSTGRE_PASSWORD" || (echo "POSTGRE_PASSWORD is not set" && exit 1)
RUN test -n "$POSTGRE_USER" || (echo "POSTGRE_USER is not set" && exit 1)
RUN test -n "$POSTGRE_HOST" || (echo "POSTGRE_HOST is not set" && exit 1)

ENV DJANGO_DB=default
ENV POSTGRE_NAME=postgres
ENV POSTGRE_PORT=5432
ENV POSTGRE_PASSWORD=$POSTGRE_PASSWORD
ENV POSTGRE_USER=$POSTGRE_USER
ENV POSTGRE_HOST=$POSTGRE_HOST

CMD ["label-studio"]
ENTRYPOINT ["label-studio"]

# This is deprecated code that is no longer needed
# This is used if you are building a static image with predefined
# Postgres credentials, however it's best if we run the image with environment
# variables passed in from the host machine
#
# E.g.
# docker run image_tag \
# -e POSTGRE_PASSWORD=pass
# -e POSTGRE_USER=user
# -e POSTGRE_HOST=host
#ARG POSTGRE_PASSWORD
#ARG POSTGRE_USER
#ARG POSTGRE_HOST
#
## Assert that the POSTGRE_PASSWORD and POSTGRE_USER
#RUN test -n "$POSTGRE_PASSWORD" || (echo "POSTGRE_PASSWORD is not set" && exit 1)
#RUN test -n "$POSTGRE_USER" || (echo "POSTGRE_USER is not set" && exit 1)
#RUN test -n "$POSTGRE_HOST" || (echo "POSTGRE_HOST is not set" && exit 1)
#ENV POSTGRE_PASSWORD=$POSTGRE_PASSWORD
#ENV POSTGRE_USER=$POSTGRE_USER
#ENV POSTGRE_HOST=$POSTGRE_HOST

0 comments on commit f3bd66a

Please sign in to comment.