Skip to content

Commit

Permalink
docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Aug 14, 2024
1 parent 01c693b commit 3e15da8
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**target*
.github/
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: docker

on:
push:
branches:
- master
tags:
- v*

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: acala/acala-node-beta
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=sha
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


21 changes: 19 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ authors = ["Acala Developers"]
version = "0.1.0"
edition = "2021"

[[bin]]
name = "acala"
path = "src/main.rs"

[dependencies]
color-eyre = { version = "0.6.3", default-features = false }

# TODO: update to a released version once available
polkadot-parachain-lib = { git = "https://github.com/serban300/polkadot-sdk", branch = "polkadot-parachain-lib" }
sc-chain-spec = { git = "https://github.com/serban300/polkadot-sdk", branch = "polkadot-parachain-lib" }
sc-cli = { git = "https://github.com/serban300/polkadot-sdk", branch = "polkadot-parachain-lib" }

[build-dependencies]
substrate-build-script-utils = "11.0.0"
orml-build-script-utils = "1.0.0"

[profile.release]
lto = true
codegen-units = 1
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM docker.io/paritytech/ci-unified:latest as builder

WORKDIR /acala
COPY . .

RUN cargo fetch
RUN cargo build --locked --release

# =============

FROM docker.io/parity/base-bin:latest
LABEL maintainer="[email protected]"

COPY --from=builder /acala/target/release/acala /usr/local/bin

USER root
RUN useradd -m -u 1001 -U -s /bin/sh -d /acala acala && \
mkdir -p /acala/data /acala/.local/share && \
chown -R acala:acala /acala/data && \
ln -s /acala/data /acala/.local/share/acala && \
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
# check if executable works in this container
/usr/local/bin/acala --version

USER acala

EXPOSE 30333 9933 9944 9615
VOLUME ["/acala/data"]

ENTRYPOINT ["/usr/local/bin/acala"]
17 changes: 17 additions & 0 deletions HEADER-GPL3
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This file is part of Acala.

// Copyright (C) 2020-2024 Acala Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
26 changes: 26 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This file is part of Acala.

// Copyright (C) 2020-2024 Acala Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

fn main() {
substrate_build_script_utils::generate_cargo_keys();
orml_build_script_utils::check_file_licenses(
"./src",
include_bytes!("./HEADER-GPL3"),
&[],
);
}

0 comments on commit 3e15da8

Please sign in to comment.