mirror of https://github.com/PiyushXCoder/lupt.git
Merge pull request #5 from PiyushXCoder/PiyushXCoder-workflow
Final woking pipeline to build docker image
This commit is contained in:
commit
dbe1de099e
25
.Dockerfile
25
.Dockerfile
|
|
@ -1,25 +0,0 @@
|
||||||
FROM rust:1-alpine3.16
|
|
||||||
|
|
||||||
ENV APP=lupt
|
|
||||||
ENV PORT=8081
|
|
||||||
|
|
||||||
RUN cargo search --limit 0 && \
|
|
||||||
apk upgrade --update-cache --available && \
|
|
||||||
apk add musl-dev && \
|
|
||||||
apk add pkgconfig && \
|
|
||||||
apk add openssl-dev && \
|
|
||||||
rm -rf /var/cache/apk/* && \
|
|
||||||
mkdir -pv /app/${APP}/etc
|
|
||||||
|
|
||||||
WORKDIR /app/${APP}
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN cargo build --release && \
|
|
||||||
cp target/release/${APP} . && \
|
|
||||||
cargo clean && \
|
|
||||||
rm -rf /usr/local/rustup/ /usr/local/cargo/ && \
|
|
||||||
apk del gcc
|
|
||||||
|
|
||||||
EXPOSE ${PORT}/tcp
|
|
||||||
|
|
||||||
CMD ./${APP} --bind-address 0.0.0.0 --port ${PORT} --config-file /app/${APP}/etc/config.json --static-path /app/${APP}/static/
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
version: "3.2"
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
container_name: lupt-chat
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- "8080:8081"
|
|
||||||
volumes:
|
|
||||||
- type: bind
|
|
||||||
source: ./etc
|
|
||||||
target: /app/lupt/etc
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
/target
|
/target
|
||||||
/etc
|
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,10 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- "main"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
push-store-image:
|
push-store-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Checkout GitHub Action'
|
- name: 'Checkout GitHub Action'
|
||||||
uses: actions/checkout@main
|
uses: actions/checkout@main
|
||||||
|
|
@ -25,6 +21,10 @@ jobs:
|
||||||
|
|
||||||
- name: 'Build Inventory Image'
|
- name: 'Build Inventory Image'
|
||||||
run: |
|
run: |
|
||||||
docker build . --tag ghcr.io/${{github.repository}}:main
|
docker buildx create --name builder1 --use --bootstrap
|
||||||
docker push ghcr.io/${{github.repository}}:main
|
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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
/target
|
/target
|
||||||
/Dockerfile
|
|
||||||
/etc/config.json
|
/etc/config.json
|
||||||
/localhost-key.pem
|
/localhost-key.pem
|
||||||
/localhost.pem
|
/localhost.pem
|
||||||
/docker-compose.yml
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue