Skip to content

Commit

Permalink
Add a workflow to deploy docker containers (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
steamroller-airmash committed Feb 26, 2022
1 parent d61f669 commit 0eda147
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 138 deletions.
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[profile.prod]
inherits = "release"
debug = true
lto = "thin"
codegen-units = 1
35 changes: 35 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

on:
workflow_dispatch:
inputs:
is_release:
default: 'true'
type: boolean
push:

name: docker

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target: [ctf, ffa, base]
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1

- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/build-push-action@v2
with:
context: .
tags: ghcr.io/steamroller-airmash/server:${{ matrix.target }}
build-args: |
TARGET=${{ matrix.target }}
push: ${{ github.event.is_release == 'true' }}

49 changes: 0 additions & 49 deletions CTF.dockerfile

This file was deleted.

54 changes: 14 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
FROM clux/muslrust:nightly
FROM rust:1.59-slim-bullseye as build-env

WORKDIR /build

RUN USER=root cargo new --bin base
COPY ./base/Cargo.toml ./base/Cargo.toml

RUN USER=root cargo new --bin bounded-queue
COPY ./bounded-queue/Cargo.toml ./bounded-queue/Cargo.toml

RUN USER=root cargo new --bin ctf
COPY ./ctf/Cargo.toml ./ctf/Cargo.toml

RUN USER=root cargo new --bin ffa
COPY ./ffa/Cargo.toml ./ffa/Cargo.toml

RUN USER=root cargo new --bin server
COPY ./server/Cargo.toml ./server/Cargo.toml

RUN USER=root cargo new --bin special-map
COPY ./special-map/Cargo.toml ./special-map/Cargo.toml

COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

RUN cargo build --release

RUN rm ./base/src/*.rs
RUN rm ./bounded-queue/src/*.rs
RUN rm ./ctf/src/*.rs
RUN rm ./ffa/src/*.rs
RUN rm ./server/src/*.rs
RUN rm ./special-map/src/*.rs
RUN apt-get update \
&& apt-get install -y dwz \
&& apt-get clean

WORKDIR /build
COPY . /build

RUN cargo build --release
RUN mkdir /artifacts
RUN mv target/x86_64-unknown-linux-musl/release/airmash-server-base /artifacts/airmash-server
ARG TARGET

FROM alpine:latest
RUN cargo build --profile prod --bin airmash-server-${TARGET}
RUN mv target/prod/airmash-server-${TARGET} target/airmash-server
RUN dwz -L none -l none --odr target/airmash-server

EXPOSE 3501
FROM debian:bullseye-slim

COPY --from=0 /artifacts/airmash-server /app/airmash-server
COPY --from=build-env /build/target/airmash-server /

ENV RUST_LOG=info,ws=warn
EXPOSE 3501/tcp
ENV RUST_LOG=info

ENTRYPOINT [ "/app/airmash-server" ]
ENTRYPOINT [ "/airmash-server" ]
49 changes: 0 additions & 49 deletions FFA.dockerfile

This file was deleted.

0 comments on commit 0eda147

Please sign in to comment.