Skip to content

Commit

Permalink
feat: add basic docker setup and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamch committed Feb 20, 2024
1 parent 65aa3d1 commit aa356a5
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
push:
tags:
- '*'

name: Build and Push Docker Image

on:
push:
tags:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v3
# Setup qemu to generate both arm and x86 images
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Setup build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ github.sha }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Data generated by Postgres
/.pgdata

# Your secrets
.env
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.21.3


WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./

RUN CGO_ENABLED=0 GOOS=linux go build -o /blood-for-life-api

CMD ["/blood-for-life-api"]
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# Blood-For-Life-Management-Backend
# Blood-For-Life-Management-Backend

### Running application locally
- Create `.env` file that contains following variables:
- POSTGRES_USER
- POSTGRES_PASSWORD
- Run `docker build -t ghcr.io/ubcsss/blood-for-life-api ./`
- Run `docker-compose up`

15 changes: 15 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'
services:
app:
image: ghcr.io/ubccsss/blood-for-life-api
ports:
- 1323:1323
db:
image: postgres:16.2
ports:
- 5432:5432
volumes:
- ./.pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}

0 comments on commit aa356a5

Please sign in to comment.