Skip to content

Commit

Permalink
Merge pull request #5 from PiyushXCoder/PiyushXCoder-workflow
Browse files Browse the repository at this point in the history
Final woking pipeline to build docker image
  • Loading branch information
PiyushXCoder authored Dec 6, 2023
2 parents e498f10 + b59a6e1 commit dbe1de0
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 46 deletions.
25 changes: 0 additions & 25 deletions .Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions .docker-compose.yml

This file was deleted.

1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/target
/etc
12 changes: 6 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
push-store-image:
runs-on: ubuntu-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
Expand All @@ -25,6 +21,10 @@ jobs:

- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/${{github.repository}}:main
docker push ghcr.io/${{github.repository}}:main
docker buildx create --name builder1 --use --bootstrap
docker buildx build --load --platform linux/arm64/v8,linux/amd64 \
--build-arg="RUNNER_GROUP_ID=${{vars.RUNNER_GROUP_ID}}" \
--build-arg="RUNNER_USER_ID=${{vars.RUNNER_USER_ID}}" \
--build-arg="APP=${{vars.APP}}" --tag ghcr.io/${GITHUB_REPOSITORY,,}:main $(pwd)
docker push ghcr.io/${GITHUB_REPOSITORY,,}:main
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/target
/Dockerfile
/etc/config.json
/localhost-key.pem
/localhost.pem
/docker-compose.yml
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM rust:alpine3.18 AS build

RUN apk add --no-cache musl-dev pkgconfig openssl-dev

WORKDIR /app
COPY . .

RUN cargo build --release




FROM alpine:3.18

ARG RUNNER_GROUP_ID=local
ENV RUNNER_GROUP_ID=${RUNNER_GROUP_ID}

ARG RUNNER_USER_ID=local
ENV RUNNER_USER_ID=${RUNNER_USER_ID}

ARG APP=local
ENV APP=${APP}

# RUN apk add --no-cache openssl

RUN addgroup -g ${RUNNER_GROUP_ID} runner && adduser -G runner -u ${RUNNER_USER_ID} runner -D
USER runner

COPY --from=build --chown=runner:runner /app/target/release/${APP} /app/app
COPY --from=build --chown=runner:runner /app/static /app/static

WORKDIR /app

CMD ./app --bind-address 0.0.0.0 --port 8000 --config-file /app/config.json --static-path /app/static
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

version: "3.2"
services:
web:
build:
context: .
args:
RUNNER_USER_ID: ${RUNNER_USER_ID}
RUNNER_GROUP_ID: ${RUNNER_GROUP_ID}
APP: ${APP}

ports:
- ${PORT}:8080
volumes:
- ${CONFIG}:/app/config.json

0 comments on commit dbe1de0

Please sign in to comment.