Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: devcontainer to build on mac #114

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "astarte-core",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:bullseye"
"build": {
"dockerfile": "../Dockerfile",
"target": "builder"
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"JakeBecker.elixir-ls",
"animus-coop.vscode-elixir-mix-formatter",
"ms-azuretools.vscode-docker"
]
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Standard Elixir gitignore to be applied to all apps
_build
cover
deps
doc
doc/doc
.fetch
db
erl_crash.dump
*.ez
*.beam
config/*.secret.exs
.elixir_ls/

# Standard Erlang gitignore to be applied to all apps
.eunit
*.o
*.beam
*.plt
.concrete/DEV_MODE

# rebar 2.x
.rebar
rel/example_project
ebin/*.beam
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM hexpm/elixir:1.17.3-erlang-26.1.2-debian-bookworm-20241111-slim as base

# install build dependencies
# --allow-releaseinfo-change allows to pull from 'oldstable'
RUN apt-get update --allow-releaseinfo-change -y && \
apt-get install -y \
build-essential \
git \
openssl \
erlang-dev \
ca-certificates \
inotify-tools && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*

# Install hex
RUN mix local.hex --force && \
mix local.rebar --force && \
mix hex.info

WORKDIR /src

FROM base as deps

ARG BUILD_ENV=prod

ENV MIX_ENV=${BUILD_ENV}

# Cache elixir deps
ADD mix.exs mix.lock ./
RUN mix do deps.get --only ${MIX_ENV}, deps.compile

FROM deps as builder

ENV MIX_ENV=${BUILD_ENV}

# Add all the rest
ADD . .
ENTRYPOINT [ "/bin/sh", "-c" ]
# ------------------------
# Only for production
FROM builder as release

ENV MIX_ENV=${BUILD_ENV}

COPY --from=builder /src .

WORKDIR /src
RUN mix do compile, release
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Astarte.Core.Mixfile do
def project do
[
app: :astarte_core,
version: "1.2.0-dev",
version: "1.2.1-dev",
elixir: "~> 1.15",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
Expand Down
Loading