refactor docker
Some checks failed
continuous-integration/drone/push Build encountered an error

This commit is contained in:
2025-08-05 19:48:55 -07:00
parent a9258136da
commit 9585408f50
7 changed files with 85 additions and 147 deletions

View File

@@ -7,7 +7,29 @@ platform:
arch: amd64
steps:
- name: api
- name: build-backend
image: golang:1.24.0
environment:
GIT_USER:
from_secret: GIT_USER
GIT_PASS:
from_secret: GIT_PASS
commands:
- echo "machine git.itzana.me login $${GIT_USER} password $${GIT_PASS}" > ~/.netrc
- chmod 600 ~/.netrc
- make build-backend
- name: build-validator
image: muslrust:1.86.0
commands:
- make build-validator
- name: build-web
image: bun:1.2.8
commands:
- make build-web
- name: image-backend
image: plugins/docker
settings:
registry: registry.itzana.me
@@ -19,16 +41,12 @@ steps:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASS
dockerfile: Containerfile
dockerfile: Dockerfile
context: .
when:
branch:
- master
- staging
event:
- push
depends_on:
- build-backend
- name: frontend
- name: image-frontend
image: plugins/docker
settings:
registry: registry.itzana.me
@@ -42,14 +60,10 @@ steps:
from_secret: REGISTRY_PASS
dockerfile: web/Containerfile
context: web
when:
branch:
- master
- staging
event:
- push
depends_on:
- build-frontend
- name: validator
- name: image-validator
image: plugins/docker
settings:
registry: registry.itzana.me
@@ -63,12 +77,8 @@ steps:
from_secret: REGISTRY_PASS
dockerfile: validation/Containerfile
context: validation
when:
branch:
- master
- staging
event:
- push
depends_on:
- build-validator
- name: deploy
image: argoproj/argocd:latest
@@ -83,9 +93,9 @@ steps:
PASSWORD:
from_secret: ARGO_PASS
depends_on:
- api
- frontend
- validator
- image-backend
- image-frontend
- image-validator
when:
branch:
- master
@@ -94,64 +104,19 @@ steps:
- push
# pr dry run
- name: api-pr
image: plugins/docker
settings:
registry: registry.itzana.me
repo: registry.itzana.me/strafesnet/maptest-validator
tags:
- ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
- ${DRONE_BRANCH}
dockerfile: Containerfile
context: .
dry_run: true
when:
event:
- pull_request
- name: frontend-pr
image: plugins/docker
settings:
registry: registry.itzana.me
repo: registry.itzana.me/strafesnet/maptest-validator
tags:
- ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
- ${DRONE_BRANCH}
dockerfile: web/Containerfile
context: web
dry_run: true
when:
event:
- pull_request
- name: validator-pr
image: plugins/docker
settings:
registry: registry.itzana.me
repo: registry.itzana.me/strafesnet/maptest-validator
tags:
- ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
- ${DRONE_BRANCH}
dockerfile: validation/Containerfile
context: validation
dry_run: true
when:
event:
- pull_request
- name: build-pr
image: alpine
commands:
- echo "Success!"
depends_on:
- api-pr
- frontend-pr
- validator-pr
- build-backend
- build-validator
- build-web
when:
event:
- pull_request
---
kind: signature
hmac: 11e6d7f1eb839d3798fdcb642ca5523c011bd14c1f3a0343a9c3106bab9ef142
hmac: 9d45e7e2eeed92974ab938b0b50e3565593927bc427fb6be8daed867403c536c
...

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
build
.idea
/target

View File

@@ -1,33 +0,0 @@
# Stage 1: Build
FROM registry.itzana.me/docker-proxy/golang:1.24 AS builder
# Set the working directory in the container
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Copy the entire project
COPY . .
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -o service ./cmd/maps-service/service.go
# Stage 2: Run
FROM registry.itzana.me/docker-proxy/alpine:3.21
# Set up a non-root user for security
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
# Set the working directory in the container
WORKDIR /home/appuser
# Copy the built application from the builder stage
COPY --from=builder /app/service .
# Expose application port (adjust if needed)
EXPOSE 8081
# Command to run the application
ENTRYPOINT ["./service"]

3
Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM alpine
COPY build/server /
ENTRYPOINT ["/server"]

View File

@@ -1,12 +1,42 @@
submissions:
DOCKER_BUILDKIT=1 docker build . -f Containerfile -t maps-service-submissions
clean:
rm -rf build
rm -rf web/build
web:
docker build web -f web/Containerfile -t maps-service-web
# build
build-backend:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o build/server cmd/maps-service/service.go
validation:
docker build validation -f validation/Containerfile -t maps-service-validation
build-validator:
cargo build --release --target x86_64-unknown-linux-musl --bin maps-validation
all: submissions web validation
build-web:
rm -rf web/build
cd web && bun install
cd web && bun run build
.PHONY: submissions web validation
build: build-backend build-validator build-web
# image
image-backend:
docker build . -t maptest-api
image-validator:
docker build validation -f validation/Containerfile -t maptest-validator
image-web:
docker build web -f web/Containerfile -t maptest-frontend
# docker
docker-backend:
make build-backend
make image-backend
docker-validator:
make build-validator
make image-validator
docker-web:
make build-web
make image-web
docker: docker-backend docker-validator docker-web
.PHONY: clean build-backend build-validator build-web build image-backend image-validator image-web docker-backend docker-validator docker-web docker

View File

@@ -1,24 +1,3 @@
# Using the `rust-musl-builder` as base image, instead of
# the official Rust toolchain
FROM registry.itzana.me/docker-proxy/clux/muslrust:1.86.0-stable AS chef
USER root
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
COPY api ./api
# Notice that we are specifying the --target flag!
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl --bin maps-validation
FROM registry.itzana.me/docker-proxy/alpine:3.21 AS runtime
RUN addgroup -S myuser && adduser -S myuser -G myuser
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/maps-validation /usr/local/bin/
USER myuser
ENTRYPOINT ["/usr/local/bin/maps-validation"]
FROM alpine:3.21 AS runtime
COPY /target/x86_64-unknown-linux-musl/release/maps-validation /
ENTRYPOINT ["/maps-validation"]

View File

@@ -1,13 +1,6 @@
FROM registry.itzana.me/docker-proxy/oven/bun:1.2.8
FROM oven/bun:1.2.8
WORKDIR /app
COPY . .
EXPOSE 3000
ENV NEXT_TELEMETRY_DISABLED=1
RUN bun install
RUN bun run build
ENTRYPOINT ["bun", "run", "start"]