Skip to content

Commit

Permalink
Merge pull request #83 from kronos-et-al/b/docker
Browse files Browse the repository at this point in the history
B/docker
  • Loading branch information
worldofjoni authored Aug 13, 2023
2 parents 284c0fe + 566385a commit 817f682
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 19 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/deploy_backend.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#
name: Publish backend to GHCR

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
workflow_dispatch:
release:
types: [published]
push:
paths: ["backend/**"]


# 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.
env:
REGISTRY: ghcr.io
IMAGE_NAME: mensa-app
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
IMAGE_NAME: kronos-et-al/mensa-app
jobs:
build-and-push-backend:
runs-on: ubuntu-latest
Expand All @@ -23,30 +21,26 @@ jobs:
permissions:
contents: read
packages: write
#

steps:
- name: Checkout repository
uses: actions/checkout@v3
# 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.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 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.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
uses: docker/metadata-action@v4
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/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
uses: docker/build-push-action@v4
with:
context: .
context: "{{defaultContext}}:backend"
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 🥘 MensaApp

<!--- [![Build-Android](https://github.com/kronos-et-al/MensaApp/actions/workflows/main.yml/badge.svg)](https://github.com/kronos-et-al/MensaApp/actions/workflows/main.yml)-->
[![Build-Rust](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml/badge.svg)](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml) [![codecov](https://codecov.io/gh/kronos-et-al/MensaApp/branch/main/graph/badge.svg?token=2CZXSPAP48)](https://codecov.io/gh/kronos-et-al/MensaApp) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kronos-et-al/MensaApp/blob/main/LICENSE) [![version](https://shields.io/github/v/release/kronos-et-al/MensaApp)](https://github.com/kronos-et-al/MensaApp/releases) ![GitHub Repo stars](https://img.shields.io/github/stars/kronos-et-al/MensaApp)
[![Build-Rust](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml/badge.svg)](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml) [![Docker](https://ghcr-badge.egpl.dev/kronos-et-al/mensa-app/size?color=%2344cc11&tag=latest&label=docker+image+size&trim=)](https://github.com/kronos-et-al/MensaApp/pkgs/container/mensa-app) [![codecov](https://codecov.io/gh/kronos-et-al/MensaApp/branch/main/graph/badge.svg?token=2CZXSPAP48)](https://codecov.io/gh/kronos-et-al/MensaApp) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kronos-et-al/MensaApp/blob/main/LICENSE) [![version](https://shields.io/github/v/release/kronos-et-al/MensaApp)](https://github.com/kronos-et-al/MensaApp/releases) ![GitHub Repo stars](https://img.shields.io/github/stars/kronos-et-al/MensaApp)


**Application for communication and collective exchange of
Expand Down
6 changes: 5 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ COPY . .
ENV SQLX_OFFLINE=true
RUN cargo install --path . --profile release

# actual running image
FROM debian:bullseye-slim
# RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*

# install http dependencies (through curl)
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/local/cargo/bin/mensa-app-backend /usr/local/bin/mensa-app-backend
EXPOSE 80/tcp

Expand Down
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The docker container can be run using
```
docker run \
-p 80:80
-e DATABASE_URL="postgres://<db user>:<db password>@<db host>:<db port>/<db name>"
-e DATABASE_URL=postgres://<db user>:<db password>@<db host>:<db port>/<db name>
-e SMTP_SERVER=<domain of mail server> \
-e SMTP_PORT=<port of mail server> \
-e SMTP_USERNAME=<username of mail server> \
Expand Down
45 changes: 45 additions & 0 deletions backend/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
services:
mensa-app:
image: ghcr.io/kronos-et-al/mensa-app
#command: --migrate # only run for the first time to create initial database structure
ports:
- 80:80
environment: # please configure accordingly <------------------------------------------------------------
- DATABASE_URL=postgres://postgres:secret_password@database/mensa_app # only change password if wanted
- SMTP_SERVER=<domain of mail server>
- SMTP_PORT=<port of mail server>
- SMTP_USERNAME=<username of mail server>
- SMTP_PASSWORD=<password of mail server>
- ADMIN_EMAIL=<email address admin notofocations should be send to>
- FLICKR_API_KEY=<flickr public api key>
- TZ=Europe/Berlin
restart: unless-stopped
depends_on:
- database
database:
image: postgres
volumes:
- dbdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=secret_password # change here and above <------------------------------------------
- POSTGRES_DB=mensa_app
- TZ=Europe/Berlin
restart: unless-stopped
admin:
image: dpage/pgadmin4
environment: # change <----------------------------------------------------------------------------------
- PGADMIN_DEFAULT_EMAIL=
- PGADMIN_DEFAULT_PASSWORD=
- TZ=Europe/Berlin
ports:
- 8888:80
volumes:
- pgadmin:/var/lib/pgadmin
restart: unless-stopped
depends_on:
- database

volumes:
dbdata:
pgadmin:

0 comments on commit 817f682

Please sign in to comment.