This commit is contained in:
Piyush मिश्रः 2023-12-06 22:22:19 +05:30
parent 508cfd7abb
commit 39092858eb
7 changed files with 51 additions and 47 deletions

View File

@ -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/

View File

@ -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

View File

@ -1,2 +1 @@
/target
/etc

View File

@ -5,9 +5,6 @@ on:
branches:
- "main"
- "PiyushXCoder-workflow"
# pull_request:
# branches:
# - "main"
jobs:
push-store-image:
@ -15,9 +12,6 @@ jobs:
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'List'
run: ls
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
@ -28,6 +22,7 @@ jobs:
- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/${GITHUB_REPOSITORY,,}:main
docker buildx build . --load --platform linux/arm64 --build-arg="RUNNER_GROUP_ID=${RUNNER_GROUP_ID}" \
--build-arg="RUNNER_USER_ID=${RUNNER_USER_ID}" --build-arg="APP=${APP}" -t --tag ghcr.io/${GITHUB_REPOSITORY,,}:main
docker push ghcr.io/${GITHUB_REPOSITORY,,}:main

2
.gitignore vendored
View File

@ -1,6 +1,4 @@
/target
/Dockerfile
/etc/config.json
/localhost-key.pem
/localhost.pem
/docker-compose.yml

34
Dockerfile Normal file
View File

@ -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
docker-compose.yml Normal file
View File

@ -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