mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-20 05:13:10 +12:00
chore: Add devcontainer configuration.
This commit is contained in:
parent
17891fceda
commit
99071f2006
5 changed files with 184 additions and 0 deletions
86
.devcontainer/Dockerfile
Normal file
86
.devcontainer/Dockerfile
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
FROM ubuntu:latest
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND="noninteractive"
|
||||||
|
|
||||||
|
# Install basic dependencies
|
||||||
|
RUN apt-get -q -y update && \
|
||||||
|
apt-get -q -y --no-install-recommends install autoconf automake \
|
||||||
|
bash build-essential bzip2 ca-certificates curl dpkg-dev file \
|
||||||
|
g++ gcc git-core imagemagick libbz2-dev libc6-dev libdb-dev libevent-dev \
|
||||||
|
libffi-dev libgdbm-dev libglib2.0-dev libgmp-dev libjpeg-dev libkrb5-dev \
|
||||||
|
liblzma-dev libmagickcore-dev libmagickwand-dev libmaxminddb-dev \
|
||||||
|
libncurses-dev libncurses5-dev libncursesw5-dev libpng-dev libpq-dev \
|
||||||
|
libreadline-dev libsctp-dev libsqlite3-dev libssl-dev libtool libwebp-dev \
|
||||||
|
libxml2-dev libxslt-dev libyaml-dev locales make make mercurial patch python3 \
|
||||||
|
unixodbc-dev unzip wget xz-utils zlib1g-dev zsh gnupg inotify-tools less \
|
||||||
|
postgresql-client ssh direnv && apt-get -q -y clean
|
||||||
|
|
||||||
|
RUN locale-gen en_AU.UTF-8
|
||||||
|
ENV LANG en_AU.UTF-8
|
||||||
|
ENV LANGUAGE en_AU:en
|
||||||
|
ENV LC_ALL en_AU.UTF-8
|
||||||
|
|
||||||
|
ARG USERNAME=vscode
|
||||||
|
ARG USER_UID=1000
|
||||||
|
ARG USER_GID=$USER_UID
|
||||||
|
RUN groupadd --gid ${USER_GID} ${USERNAME}
|
||||||
|
RUN useradd --shell /usr/bin/zsh --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}
|
||||||
|
RUN mkdir /workspace && chown ${USERNAME}:${USERNAME} /workspace
|
||||||
|
RUN touch /entrypoint.sh && chown ${USERNAME}:${USERNAME} /entrypoint.sh
|
||||||
|
RUN mkdir -p /var/tmp/history && chown -R ${USERNAME}:${USERNAME} /var/tmp/history
|
||||||
|
RUN mkdir /storage && chown ${USERNAME}:${USERNAME} /storage
|
||||||
|
|
||||||
|
USER ${USERNAME}
|
||||||
|
ENV HOME=/home/${USERNAME}
|
||||||
|
|
||||||
|
WORKDIR $HOME
|
||||||
|
|
||||||
|
# Install oh-my-zsh
|
||||||
|
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||||
|
|
||||||
|
RUN echo '\neval "$(direnv hook zsh)"' >> ~/.zshrc
|
||||||
|
|
||||||
|
# Install ASDF
|
||||||
|
ARG ASDF_VERSION=0.10.2
|
||||||
|
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v${ASDF_VERSION} && \
|
||||||
|
echo '\nsource $HOME/.asdf/asdf.sh' >> ~/.bashrc && \
|
||||||
|
echo '\nsource $HOME/.asdf/asdf.sh' >> ~/.zshrc
|
||||||
|
|
||||||
|
WORKDIR /workspace/
|
||||||
|
RUN mkdir _build deps .elixir_ls
|
||||||
|
|
||||||
|
# Install all the tools specified in the tool versions file.
|
||||||
|
COPY .tool-versions /workspace/
|
||||||
|
RUN /bin/bash -c 'source ~/.asdf/asdf.sh && \
|
||||||
|
cat .tool-versions | cut -d \ -f 1 | xargs -n 1 asdf plugin add && \
|
||||||
|
asdf install && \
|
||||||
|
cat .tool-versions | xargs -n 2 asdf global'
|
||||||
|
|
||||||
|
# Elixir and Erlang setup (we just assume that Elixir was in the .tool-versions file)
|
||||||
|
ARG HEX_API_KEY
|
||||||
|
RUN /bin/bash -c 'source ~/.asdf/asdf.sh && \
|
||||||
|
mix local.rebar --force && \
|
||||||
|
mix local.hex --force'
|
||||||
|
ENV ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"/var/tmp/history/erlang.history\"'"
|
||||||
|
|
||||||
|
# Generate an entrypoint.sh
|
||||||
|
RUN echo '#!/bin/bash' > /entrypoint.sh && \
|
||||||
|
echo 'source ~/.asdf/asdf.sh' >> /entrypoint.sh && \
|
||||||
|
echo 'eval "$(direnv hook bash)"' >> /entrypoint.sh && \
|
||||||
|
echo 'exec "$@"' >> /entrypoint.sh && \
|
||||||
|
chmod 755 /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
|
|
||||||
|
# Prodigious use of asterisk to allow for files which may not exist.
|
||||||
|
COPY .env* .formatter.exs .tool-versions* bin* config* lib* priv* rel* test* CHANGELOG.md* mix.* /workspace/
|
||||||
|
|
||||||
|
RUN /bin/bash -c 'if [ -e .envrc ]; then /usr/bin/direnv allow; fi'
|
||||||
|
|
||||||
|
# Run mix deps.get
|
||||||
|
ARG GITHUB_TOKEN
|
||||||
|
RUN /bin/bash -c 'source ~/.asdf/asdf.sh && \
|
||||||
|
mix deps.get'
|
||||||
|
|
||||||
|
CMD ["zsh"]
|
||||||
|
|
38
.devcontainer/devcontainer.json
Normal file
38
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||||
|
// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/elixir-phoenix-postgres
|
||||||
|
{
|
||||||
|
"name": "ASDF, Elixir and Postgres",
|
||||||
|
"dockerComposeFile": "docker-compose.yml",
|
||||||
|
"service": "app",
|
||||||
|
"workspaceFolder": "/workspace",
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
"customizations": {
|
||||||
|
// Configure properties specific to VS Code.
|
||||||
|
"vscode": {
|
||||||
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
|
"extensions": [
|
||||||
|
"jakebecker.elixir-ls",
|
||||||
|
"msaraiva.surface",
|
||||||
|
"ue.alphabetical-sorter",
|
||||||
|
"wmaurer.change-case",
|
||||||
|
"Rubymaniac.vscode-direnv",
|
||||||
|
"RoyalMist.vscode-eex-format",
|
||||||
|
"iampeterbanjo.elixirlinter",
|
||||||
|
"pgourlain.erlang",
|
||||||
|
"szTheory.erlang-formatter",
|
||||||
|
"bradlc.vscode-tailwindcss"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// This can be used to network with other containers or with the host.
|
||||||
|
"forwardPorts": [
|
||||||
|
4000,
|
||||||
|
4001,
|
||||||
|
5432
|
||||||
|
],
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
// "postCreateCommand": "mix deps.get"
|
||||||
|
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
|
||||||
|
"remoteUser": "vscode"
|
||||||
|
}
|
56
.devcontainer/docker-compose.yml
Normal file
56
.devcontainer/docker-compose.yml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
apt-cache: {}
|
||||||
|
history: {}
|
||||||
|
db-data: {}
|
||||||
|
app-deps: {}
|
||||||
|
app-build: {}
|
||||||
|
app-elixir-ls: {}
|
||||||
|
app-asdf: {}
|
||||||
|
app-storage: {}
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
environment:
|
||||||
|
LOGGER_LEVEL: 1
|
||||||
|
PGHOST: db
|
||||||
|
PGPORT: 5432
|
||||||
|
PGUSER: postgres
|
||||||
|
PGDATABASE: app
|
||||||
|
HISTFILE: /var/tmp/history/shell.history
|
||||||
|
GIT_AUTHOR_EMAIL:
|
||||||
|
GIT_COMMITTER_EMAIL:
|
||||||
|
GITHUB_TOKEN:
|
||||||
|
PORT: 400
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: .devcontainer/Dockerfile
|
||||||
|
args:
|
||||||
|
HEX_API_KEY:
|
||||||
|
GITHUB_TOKEN:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- ..:/workspace:cached
|
||||||
|
- "apt-cache:/var/cache/apt:rw"
|
||||||
|
- "history:/var/tmp/history:rw"
|
||||||
|
- "app-asdf:/home/vscode/.asdf:rw"
|
||||||
|
- "app-deps:/workspace/deps:rw"
|
||||||
|
- "app-build:/workspace/_build:rw"
|
||||||
|
- "app-elixir-ls:/workspace/.elixir_ls:rw"
|
||||||
|
- "app-storage:/storage:rw"
|
||||||
|
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
|
||||||
|
network_mode: service:db
|
||||||
|
|
||||||
|
# Overrides default command so things don't shut down after the process ends.
|
||||||
|
command: sleep infinity
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- db-data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_HOST_AUTH_METHOD: trust
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -24,3 +24,5 @@ ash_authentication-*.tar
|
||||||
|
|
||||||
# Temporary files, for example, from tests.
|
# Temporary files, for example, from tests.
|
||||||
/tmp/
|
/tmp/
|
||||||
|
|
||||||
|
.env*
|
||||||
|
|
2
.tool-versions
Normal file
2
.tool-versions
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
elixir 1.14.0
|
||||||
|
erlang 25.1
|
Loading…
Reference in a new issue