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: update to latest runtime for golang runtimes #17

Merged
merged 2 commits into from
Mar 24, 2024
Merged
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
44 changes: 30 additions & 14 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
FROM mcr.microsoft.com/vscode/devcontainers/base:1-focal
FROM mcr.microsoft.com/devcontainers/base:jammy

ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
ENV PATH=$PATH:/usr/local/go/bin:

COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/

RUN apt update && apt install -y \
build-essential \
curl \
gettext-base \
git \
jq \
less \
unzip \
vim \
wget \
xxd

# install go
ARG GOLANG_VERSION=1.22.1
RUN SYSTEM_ARCH=$(dpkg --print-architecture) \
&& curl -sL "https://go.dev/dl/go${GOLANG_VERSION}.linux-${SYSTEM_ARCH}.tar.gz" | tar -C /usr/local -xzf - \
&& /usr/local/go/bin/go install -v golang.org/x/tools/gopls@latest

# install aws
RUN SYSTEM_ARCH=$(uname -m) \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-${SYSTEM_ARCH}.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-${SYSTEM_ARCH}-2.13.33.zip" -o "awscliv2.zip" \
&& unzip -qq awscliv2.zip \
&& aws/install \
&& aws --version \
&& rm -rf aws

# install terraform
Expand All @@ -22,19 +45,12 @@ RUN SYSTEM_ARCH=$(dpkg --print-architecture) \
# install tflint
RUN curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

# install docker
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/

# install node.js
ENV NODE_VERSION=18.x
RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - && \
apt-get install -y nodejs \
&& npm install -g typescript
# arkade
RUN curl -sLS https://get.arkade.dev | sh

# verify installs
RUN terraform --version \
&& aws --version \
&& node --version \
&& npm --version \
&& tsc --version \
&& docker --version
WORKDIR /
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Terraform",
"dockerFile": "Dockerfile",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2.3.0": {}
"ghcr.io/devcontainers/features/docker-in-docker:2.10.1": {}
},
"mounts": [
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
Expand Down Expand Up @@ -41,4 +41,4 @@
]
}
}
}
}
6 changes: 3 additions & 3 deletions assets/yopass-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# --------------------------------------------------------------------- base ---

FROM golang:1.19 as base
FROM golang:1.22.1 as base

ARG YOPASS_VERSION=latest

Expand All @@ -16,13 +16,13 @@ RUN if [ "$YOPASS_VERSION" != "latest" ] ; then git checkout $YOPASS_VERSION ; f
RUN go mod download
RUN cd deploy/aws-lambda && \
go mod tidy && \
go build -o main
go build -o bootstrap

# ------------------------------------------------------------------ package ---

FROM alpine:latest as package

COPY --from=base /opt/app/deploy/aws-lambda/main /opt/app/dist/main
COPY --from=base /opt/app/deploy/aws-lambda/bootstrap /opt/app/dist/bootstrap

RUN apk add zip \
&& cd /opt/app/dist \
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ resource "aws_lambda_function" "this" {

function_name = module.yopass_label.id
filename = module.yopass_server_code.artifact_package_path
handler = "main"
runtime = "go1.x"
timeout = 45
handler = "bootstrap"
runtime = "provided.al2023"
timeout = 15
role = aws_iam_role.this[0].arn
layers = []

Expand Down
Loading